map(object, path, transform) ⇒ Object | Array.<any>

one of additional functions to work with array items

Returns: Object | Array.<any> - updated object Params

  • object Object | Array.<any> - object to update
  • path string | Array.<string> - path to be updated
  • transform function - transform function

Description

import { map } from 'immutable-object-update';

const state = {
    a: {
        b: [ 1, 2, 3 ]
    }
};
const add2 = item => item + 2;

const updated = filter(state, [ 'a', 'b' ], add2);

// or

const updated = filter(state, 'a.b', add2);

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

{
    a: {
        b: [ 3, 4, 5 ]
    }
}

results matching ""

    No results matching ""