pipe(...ops) ⇒ function

Combines several operations into one (to upply later)

Returns: function - combined update operation Params

  • ...ops function - operations to combine

Description

import { pipe, set } from 'immutable-object-update';

const state = {
    a: {
        a1: 1,
        a2: 2
    },
    b: {
        b1: 3,
        b2: 4
    }
};

const setA1to10andB1to30 = pipe(
    set('a.a1', 10),
    set('b.b1', 30)
);

const updated = setA1to10andB1to30(state);

As a result we will receive new object with structure below:

{
    a: {
        a1: 10,
        a2: 2
    },
    b: {
        b1: 30,
        b2: 5
    }
}

results matching ""

    No results matching ""