seq

Methods

(static) chain(object, [path]) → {Object}

Source:
Since:
  • 0.1.8
See:
  • value for more information.
Creates an immutadot wrapper instance that wraps object allowing to make sequences of immutadot functions calls on it.
The result of such sequences must be unwrapped with value.
The object on which the functions are called may be changed with an optional path.
Examples

Chain several operations

chain({ nested1: { prop: 'old' }, nested2: { prop: 1 } })
  .set('nested1.prop', 'new')
  .unset('nested2.prop')
  .value() // => { nested1: { prop: 'new' }, nested2: {} }

Chain on a path

chain({ nested: { prop1: 'old', prop2: 1 } }, 'nested')
  .set('prop1', 'new')
  .unset('prop2')
  .value() // => { nested: { prop1: 'new' } }
Parameters:
Name Type Attributes Description
object Object The object to wrap.
path Array | string
optional
The path of the object on which functions are called.
Returns:
Returns the new immutadot wrapper instance.
Type
Object

value() → {Object}

Source:
Since:
  • 0.1.8
See:
  • chain for more information.
Executes the chain sequence and returns the unwrapped object.
Example
chain({ nested1: { prop: 'old' }, nested2: { prop: 1 } })
  .set('nested1.prop', 'new')
  .unset('nested2.prop')
  .value() // => { nested1: { prop: 'new' }, nested2: {} }
Returns:
Returns the resolved unwrapped object.
Type
Object

Type Definitions

peekCallback(unwrapped)

Source:
Since:
  • 0.3.0
Function to be called by peek with the resolved unwrapped value.
Parameters:
Name Type Description
unwrapped Object The resolved unwrapped object