The current code is able to change values for selector paths which already exist in the obj. It would be nice if there were support for 'upsert' which would update a field if the selector path already exists, OR add a field and selector path if the path does not exist.
This following works, because the selector path ["a", "b"] already exists in the 'obj' {a: {b: "before"}.
m.change(["a", "b"], "after")({a: {b: "before"})
The result is:
It would be nice if
m.upsert(["a", "b"], "after")({}) // Note the empty obj({})
Would produce the same result as above, even though the selector path ["a", "b"] does not exist in the obj {}.
The current code is able to change values for selector paths which already exist in the obj. It would be nice if there were support for 'upsert' which would update a field if the selector path already exists, OR add a field and selector path if the path does not exist.
This following works, because the selector path
["a", "b"]already exists in the 'obj'{a: {b: "before"}.The result is:
It would be nice if
Would produce the same result as above, even though the selector path
["a", "b"]does not exist in the obj{}.