object

Methods

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

Source:
Since:
  • 0.1.12
See:
Replaces by an object assigning 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) defaults(object, path, […sources]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an object assigning own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined.
Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored.
Example
defaults({ nested: { a: 1, b: 2 } }, 'nested', { b: 3, c: 4 }) // => { nested: { a:1, b: 2, 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) mapKeys(object, path, [iteratee]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an object with the same values as the former object and values generated by running each own enumerable string keyed property of the former object thru iteratee. The iteratee is invoked with three arguments: (value, key, object).
Example
mapKeys({ nested: { a: 1, b: 2, c: 3 } }, 'nested', (v, k) => '_' + k) // => { nested: { _a: 1, _b: 2, _c: 3 } }
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) mapValues(object, path, [iteratee]) → {Object}

Source:
Since:
  • 0.1.12
See:
Replaces by an object with the same keys as the former 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) merge(object, path, […sources]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an object deeply merging own enumerable string keyed properties of source objects to the former object.
Source objects are applied from left to right. Subsequent sources overwrite properties of previous sources.
Example
merge({ nested: { prop: { a: 1 } } }, 'nested', { prop: { a: 2, b: 3 } }) // => { nested: { prop: { a: 2, b: 3 } } }
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) omit(object, path, […paths]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an object omitting specified properties.
Example
omit({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { a:1, c: 3 } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
paths string | Array.<string>
optional
repeatable
The property paths to omit.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.3.0
See:
Replaces by an object omitting properties that predicate doesn't return truthy for.
Example
omitBy({ nested: { a: 1, b: 2, c: 3 } }, 'nested', v => v === 2) // => { nested: { a:1, c: 3 } }
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 property.
Returns:
Returns the updated object.
Type
Object

(static) pick(object, path, […paths]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an object picking specified properties.
Example
pick({ nested: { a: 1, b: 2, c: 3 } }, 'nested', 'b') // => { nested: { b: 2 } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
paths string | Array.<string>
optional
repeatable
The property paths to pick.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.1.12
See:
Replaces by an object picking properties that predicate returns truthy for.
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