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, …arrays) → {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.
arrays Array
repeatable
The arrays of values to exclude.
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) 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) 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) 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) 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