array

Methods

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

Source:
Since:
  • 0.1.7
See:
Replaces by a new array containing the elements of the former array and one or more elements added to the end.
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) xor(object, path, …arrays) → {Array}

Source:
Since:
  • 0.1.6
See:
Replaces by an array of unique values that is 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 new array of filtered values.
Type
Array