collection

Methods

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

Source:
Since:
  • 1.0.0
See:
Replaces by an array of elements predicate returns truthy for.
Example
filter({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [1, 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 iteration.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 1.0.0
See:
Replaces by an array of values by running each element in the former collection thru iteratee. The iteratee is invoked with three arguments: (value, index|key, collection).
Example
map({ nested: { prop: [1, 2, 3] } }, 'nested.prop', v => v * 2) // => { nested: { prop: [2, 4, 6] } }
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) orderBy(object, path, [iteratees], [orders]) → {Object}

Source:
Since:
  • 1.0.0
See:
Replaces by an array of sorted by iteratees in specified orders.
Example
orderBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'], ['asc', 'desc'])
// => { nested: { prop: [{ name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }, { name: 'Yvo', age: 2 }] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
iteratees Array.<Array> | Array.<function()> | Array.<Object> | Array.<string>
optional
[lodash.identity] The iteratees to sort by.
orders Array.<string>
optional
The sort orders of iteratees.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 1.0.0
See:
Replaces by an array of elements predicate returns falsy for.
Example
reject({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v % 2) // => { nested: { prop: [2, 4] } }
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) shuffle(object, path) → {Object}

Source:
Since:
  • 1.0.0
See:
Replaces by an array of shuffled elements.
Example
shuffle({ nested: { prop: [1, 2, 3, 4, 5, 6, 7, 8, 9] } }, 'nested.prop') // => { nested: { prop: [7, 3, 9, 1, 4, 5, 6, 8, 2] } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
Returns:
Returns the updated object.
Type
Object

(static) sortBy(object, path, [iteratees]) → {Object}

Source:
Since:
  • 1.0.0
See:
Replaces by an array of sorted by iteratees.
Example
sortBy({ nested: { prop: [{ name: 'Yvo', age: 2 }, { name: 'Nico', age: 666 }, { name: 'Nico', age: 30 }] } }, 'nested.prop', ['name', 'age'])
// => { nested: { prop: [{ name: 'Nico', age: 30 }, { name: 'Nico', age: 666 }, { name: 'Yvo', age: 2 }] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
iteratees Array.<Array> | Array.<function()> | Array.<Object> | Array.<string>
optional
[lodash.identity] The iteratees to sort by.
Returns:
Returns the updated object.
Type
Object