util

Methods

(static) using(…paths) → {Object}

Source:
Since:
  • 0.1.12
Allows to specify one or several paths to use as arguments for an immutadot function call.
Examples

Add b to a

const o = { nested: { a: 2, b: 3 } }
using('nested.b').add(o, 'nested.a') // => { nested: { a: 5, b: 3 } }

Replace a by a * b + c

const o = { nested: { a: 2, b: 3, c: 4 } }
using('nested.b', 'nested.c')
  .update(o, 'nested.a', (a, b, c) => a * b + c) // => { nested: { a: 10, b: 3, c: 4 } }
Parameters:
Name Type Attributes Description
paths Array | string
repeatable
The paths to use as arguments.
Returns:
Returns an object with immutadot functions.
Type
Object