object

Methods

(static) assign(object, path, […sources]) → {Object}

Source:
Since:
  • 0.1.12
See:
Assigns own enumerable string keyed properties of source objects to the destination object. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.
Example
assign({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 3, c: 4 } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
sources Object
optional
repeatable
The source objects.
Returns:
Returns the updated object.
Type
Object

(static) mapValues(object, path, [iteratee]) → {Object}

Source:
Since:
  • 0.1.12
See:
Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee. The iteratee is invoked with three arguments: (value, key, object).
Examples
mapValues({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v * v) // => { nested: { a:1, b: 4, c: 9 } }
mapValues({ nested: { a: { age: 40, name: 'John' }, b: { age: 30, name: 'Alice' } } }, 'nested', 'age')
// => { nested: { a: 40, b: 30 } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
iteratee function
optional
lodash.identity The function invoked per iteration.
Returns:
Returns the updated object.
Type
Object

(static) pickBy(object, path, [predicate]) → {Object}

Source:
Since:
  • 0.1.12
See:
Creates an object composed of the object properties predicate returns truthy for. The predicate is invoked with two arguments: (value, key).
Example
pickBy({ nested: { a: 1, b: 2, c: 3, d: 4 } }, 'nested', v => v < 3) // => { nested: { a: 1, b: 2 } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
predicate function
optional
lodash.identity The function invoked per iteration.
Returns:
Returns the updated object.
Type
Object

(static) set(object, path, value) → {Object}

Source:
Since:
  • 0.1.5
See:
Sets the value at path of object. This is the lodash/fp set, with no arguments rearranging and no currying.
Example
set({ nested: { prop: 'old' } }, 'nested.prop', 'new') // => { nested: { prop: 'new' } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
value * The value to set.
Returns:
Returns the updated object.
Type
Object

(static) unset(object, path) → {Object}

Source:
Since:
  • 0.1.5
See:
Removes the property at path of object. This is the lodash/fp unset, with no arguments rearranging and no currying.
Example
unset({ nested: { prop: 'value' } }, 'nested.prop') // => { nested: {} }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to unset.
Returns:
Returns the updated object.
Type
Object

(static) update(object, path, updater, …args) → {Object}

Source:
Since:
  • 0.1.5
See:
Updates the value at path of object using the updater function.
The updater is invoked with value and …args.
Be carefull, the updater function must not mutate its value argument.
Example

Updating a prop

const inc = (v, i = 1) => v + i // this function increments a number with an optional value which defaults to 1
const object = { nested: { prop: 4 } }
update(object, 'nested.prop', inc) // => { nested: { prop: 5 } }
update(object, 'nested.prop', inc, 2) // => { nested: { prop: 6 } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
updater function The function to produce the updated value.
args *
repeatable
The remaining args.
Returns:
Returns the updated object.
Type
Object