math

Methods

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

Source:
Since:
  • 0.1.7
See:
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) divide(object, path, divisor) → {Object}

Source:
Since:
  • 0.3.0
See:
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:
  • 0.3.0
See:
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) subtract(object, path, subtrahend) → {Object}

Source:
Since:
  • 0.3.0
See:
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