Updates the value at given path of given object. It does not mutate the object but returns a new one. If path is not
found then objects are created "on the way". If non-objects are found, they are replaced with new plain objects. If
primitives are used as source they are ignored and returned value is empty object with updated value at given path.
This is still too dynamic in nature to get full TypeScript support. Properties are not typed, return type is unknown.
It is recommended to use immutable-assign package instead.
Example
set(object, "deep.property", value)
Example
set(object, ["deep", "property"], value)
Example
set({}, "deep[0].property", value) // will create this structure: { "deep[0]": { "property":value }}
Example
set({}, "items.0", value) // will create an object, not an array { "items": { "0":value }}
Updates the value at given path of given object. It does not mutate the object but returns a new one. If path is not found then objects are created "on the way". If non-objects are found, they are replaced with new plain objects. If primitives are used as source they are ignored and returned value is empty object with updated value at given path.
This is still too dynamic in nature to get full TypeScript support. Properties are not typed, return type is unknown. It is recommended to use
immutable-assign
package instead.Example
Example
Example
Example