array

Methods

(static) concat(object, path, …arrays) → {Object}

Source:
Since:
  • 0.2.0
See:
Replaces an array concatenating the former array with additional arrays and/or values.
Example
concat({ nested: { prop: [1, 2] } }, 'nested.prop', [3, 4]) // => { nested: { prop: [1, 2, 3, 4] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
repeatable
The arrays to concatenate.
Returns:
Returns the updated object.
Type
Object

(static) difference(object, path, …values) → {Object}

Source:
Since:
  • 0.2.0
See:
Replaces an array removing values in the other given arrays from the former array.
Example
difference({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array
repeatable
The arrays of values to exclude.
Returns:
Returns the updated object.
Type
Object

(static) differenceBy(object, path, …values, [iteratee]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.difference except that it uses iteratee to generate the value to be compared for each element.
Example
differenceBy({ nested: { prop: [1.2, 3.4, 5.6] } }, 'nested.prop', [5.4, 2.1], Math.floor) // => { nested: { prop: [1.2, 3.4] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array
repeatable
The arrays of values to exclude.
iteratee function
optional
lodash.identity The iteratee invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) differenceWith(object, path, …values, [comparator]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.difference except that it uses comparator to compare elements of the former array to values.
Example
differenceWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array
repeatable
The arrays of values to exclude.
comparator function
optional
The comparator invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) drop(object, path, [n]) → {Object}

Source:
Since:
  • 0.2.0
See:
Replaces an array dropping one or several elements at the start of the former array.
Example
drop({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
n number
optional
1 The number of elements to drop.
Returns:
Returns the updated object.
Type
Object

(static) dropRight(object, path, [n]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array dropping one or several elements at the end of the former array.
Example
dropRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
n number
optional
1 The number of elements to drop.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.3.0
See:
Replaces an array excluding elements dropped from the end. Elements are dropped until predicate returns falsey.
Example
dropRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 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) dropWhile(object, path, [predicate]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey.
Example
dropWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 3) // => { nested: { prop: [3, 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) fill(object, path, value, [start], [end]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an array filled with value from start up to, but not including, end.
Example
fill({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 6, 1, 3) // => { nested: { prop: [1, 6, 6, 4] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
value * The value to fill array with.
start number
optional
0
end number
optional
array.length
Returns:
Returns the updated object.
Type
Object

(static) intersection(object, path, […arrays]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces by an array of unique values that are included in th former array and all given arrays.
Example
intersection({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [2] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
Returns:
Returns the updated object.
Type
Object

(static) intersectionBy(object, path, […arrays], [iteratee]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.intersection except that it uses iteratee to generate the value to be compared for each element.
Example
intersectionBy({ nested: { prop: [1.2, 2.1] } }, 'nested.prop', [2.3, 3.2], Math.floor) // => { nested: { prop: [2.1] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
iteratee function
optional
lodash.identity The iteratee invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) intersectionWith(object, path, […arrays], [comparator]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.intersection except that it uses comparator to compare elements of the former array to arrays.
Example
intersectionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
comparator function
optional
The comparator invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) pull(object, path, …values) → {Object}

Source:
Since:
  • 0.2.0
See:
Replaces an array removing all given values from the former array.
Example
pull({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', 1, 3) // => { nested: { prop: [2, 2] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values *
repeatable
The values to remove.
Returns:
Returns the updated object.
Type
Object

(static) pullAll(object, path, values) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.pull except that it accepts an array of values to remove.
Example
pullAll({ nested: { prop: [1, 2, 3, 1, 2, 3] } }, 'nested.prop', [1, 3]) // => { nested: { prop: [2, 2] } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array The values to remove.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.3.0
See:
This method is like array.pullAll except that it accepts iteratee to generate the criterion by which each element is compared.
Example
pullAllBy({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array The values to remove.
iteratee function
optional
lodash.identity The iteratee invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) pullAllWith(object, path, values, [comparator]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.pullAll except that it accepts comparator to compare elements.
Example
pullAllWith({ nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }, { x: 2 }, { x: 3 }] } }, 'nested.prop', [{ x: 1 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 2 }, { x: 2 }] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values Array The values to remove.
comparator function
optional
The comparator invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) pullAt(object, path, […indexes]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array removing the specified indexes from the former array.
Example
pullAt({ nested: { prop: [4, 3, 2, 1] } }, 'nested.prop', 1, 3) // => { nested: { prop: [4, 2] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
indexes number | Array.<number>
optional
repeatable
The indexes of elements to remove.
Returns:
Returns the updated object.
Type
Object

(static) push(object, path, …values) → {Object}

Source:
Since:
  • 0.1.7
See:
Replaces an array adding one or more elements to the end of the former array.
Examples

Add one element.

push({ nested: { prop: [1, 2] } }, 'nested.prop', 3) // => { nested: { prop: [1, 2, 3] } }

Add several elements.

push({ nested: { prop: [1, 2] } }, 'nested.prop', 3, 4) // => { nested: { prop: [1, 2, 3, 4] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values *
repeatable
The values to add.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.2.0
See:
Replaces an array removing elements that predicate returns truthy for from the former array.
Example
remove({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 2) // => { nested: { prop: [1, 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) reverse(object, path) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array reversing the elements from the former array.
Example
reverse({ nested: { prop: [1, 2, 3] } }, 'nested.prop') // => { nested: { prop: [3, 2, 1] } }
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) slice(object, path, [start], [end]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array by a slice of the former array from start up to, but not including, end.
Example
slice({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 1, 3) // => { nested: { prop: [2, 3] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
start number
optional
0 The start position.
end number
optional
array.length The end position.
Returns:
Returns the updated object.
Type
Object

(static) splice(object, path, start, [deleteCount], …values) → {Object}

Source:
Since:
  • 0.2.0
See:
Replaces an array removing and/or adding elements at index in the former array.
Example
splice({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 1, 2, 5, 6) // => { nested: { prop: [1, 5, 6, 4] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
start number Index at which to start changing the array.
deleteCount number
optional
The number of old array elements to remove.
values *
repeatable
The values to add.
Returns:
Returns the updated object.
Type
Object

(static) take(object, path, [n]) → {Object}

Source:
Since:
  • 0.3.0
See:
Creates a slice of array with n elements taken from the beginning.
Example
take({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [1, 2] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
n number
optional
1 Number of elements to take from the beginning of the array.
Returns:
Returns the updated object.
Type
Object

(static) takeRight(object, path, [n]) → {Object}

Source:
Since:
  • 0.3.0
See:
Creates a slice of array with n elements taken from the end.
Example
takeRight({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', 2) // => { nested: { prop: [3, 4] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
n number
optional
1 Number of elements to take from the end of the array.
Returns:
Returns the updated object.
Type
Object

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

Source:
Since:
  • 0.3.0
See:
Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).
Example
takeRightWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v > 3) // => { nested: { prop: [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) takeWhile(object, path, [predicate]) → {Object}

Source:
Since:
  • 0.3.0
See:
Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).
Example
takeWhile({ nested: { prop: [1, 2, 3, 4] } }, 'nested.prop', v => v < 2) // => { nested: { prop: [1] } }
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) union(object, path, […arrays]) → {Object}

Source:
Since:
  • 0.3.0
See:
Replaces an array by an array of unique values, in order, from the former array and the given arrays.
Example
union({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 2, 3] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
Returns:
Returns the updated object.
Type
Object

(static) unionBy(object, path, […arrays], [iteratee]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.union except that it accepts iteratee to generate the criterion by which elements are compared.
Example
unionBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
iteratee function
optional
lodash.identity The iteratee invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) unionWith(object, path, […arrays], [comparator]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.union except that it accepts comparator to compare elements.
Example
unionWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === b.x) // => { nested: { prop: [{ x: 1 }, { x: 2 }, { x: 3 }] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
optional
repeatable
The arrays to inspect.
comparator function
optional
The comparator invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) unshift(object, path, …values) → {Object}

Source:
Since:
  • 0.1.7
See:
Replaces an array adding elements at the start of the former array.
Examples

Add one element.

unshift({ nested: { prop: [1, 2] } }, 'nested.prop', 3) // => { nested: { prop: [3, 1, 2] } }

Add several elements.

unshift({ nested: { prop: [1, 2] } }, 'nested.prop', 3, 4) // => { nested: { prop: [3, 4, 1, 2] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
values *
repeatable
The values to add.
Returns:
Returns the updated object.
Type
Object

(static) xor(object, path, …arrays) → {Object}

Source:
Since:
  • 0.1.6
See:
Replaces an array by the symmetric difference of the former array and the given arrays.
Example
xor({ nested: { prop: [1, 2] } }, 'nested.prop', [2, 3]) // => { nested: { prop: [1, 3] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
repeatable
The arrays to inspect.
Returns:
Returns the updated object.
Type
Object

(static) xorBy(object, path, …arrays, [iteratee]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.xor except that it accepts iteratee to generate the criterion by which elements are compared.
Example
xorBy({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], 'x') // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
Parameters:
Name Type Attributes Default Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
repeatable
The arrays to inspect.
iteratee function
optional
lodash.identity The iteratee invoked per element.
Returns:
Returns the updated object.
Type
Object

(static) xorWith(object, path, …arrays, [comparator]) → {Object}

Source:
Since:
  • 0.3.0
See:
This method is like array.xor except that it accepts comparator to compare elements.
Example
xorWith({ nested: { prop: [{ x: 1 }, { x: 2 }] } }, 'nested.prop', [{ x: 2 }, { x: 3 }], (a, b) => a.x === a.b) // => { nested: { prop: [{ x: 1 }, { x: 3 }] } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
arrays Array
repeatable
The arrays to inspect.
comparator function
optional
The comparator invoked per element.
Returns:
Returns the updated object.
Type
Object