lang

Methods

(static) add(object, path, addend) → {Object}

Source:
Since:
  • 1.0.0
Replaces by the addition of the former number and the given number.
Example
add({ nested: { prop: 2 } }, 'nested.prop', 4) // => { nested: { prop: 6 } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
addend number The number to add.
Returns:
Returns the updated object.
Type
Object

(static) and(object, path, […args]) → {Object}

Source:
Since:
  • 1.0.0
Applies && between the former value and args
Examples
and({ nested: { prop: true } }, 'nested.prop', true) // { nested: { prop: true } }
and({ nested: { prop: true } }, 'nested.prop', true, false) // { nested: { prop: false } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
args *
optional
repeatable
Other operands.
Returns:
Returns the updated object.
Type
Object

(static) divide(object, path, divisor) → {Object}

Source:
Since:
  • 1.0.0
Replaces by the division of the former number and the given number.
Example
divide({ nested: { prop: 1332 } }, 'nested.prop', 2) // => { nested: { prop: 666 } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
divisor number The second number in the division.
Returns:
Returns the updated object.
Type
Object

(static) multiply(object, path, multiplicand) → {Object}

Source:
Since:
  • 1.0.0
Replaces by the multiplication of the former number and the given number.
Example
multiply({ nested: { prop: 333 } }, 'nested.prop', 2) // => { nested: { prop: 666 } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
multiplicand number The second number in the multiplication.
Returns:
Returns the updated object.
Type
Object

(static) or(object, path, […args]) → {Object}

Source:
Since:
  • 1.0.0
Applies || between the former value and args
Examples
or({ nested: { prop: false } }, 'nested.prop', true) // { nested: { prop: true } }
or({ nested: { prop: true } }, 'nested.prop', false, false) // { nested: { prop: true } }
Parameters:
Name Type Attributes Description
object Object The object to modify.
path Array | string The path of the property to set.
args *
optional
repeatable
Other operands.
Returns:
Returns the updated object.
Type
Object

(static) subtract(object, path, subtrahend) → {Object}

Source:
Since:
  • 1.0.0
Replaces by the subtraction of the former number by the given number.
Example
subtract({ nested: { prop: 2000 } }, 'nested.prop', 336) // => { nested: { prop: 1664 } }
Parameters:
Name Type Description
object Object The object to modify.
path Array | string The path of the property to set.
subtrahend number The number to subtract.
Returns:
Returns the updated object.
Type
Object

(static) toggle(object, path) → {Object}

Source:
Since:
  • 0.1.5
Applies ! to the property.
Example
toggle({ nested: { prop: true } }, 'nested.prop') // { nested: { prop: false } }
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