shift(object, path) ⇒ 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

Description

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

const state = {
    a: {
        b: [ 1, 2, 3 ]
    }
};

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

// or

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

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

{
    a: {
        b: [ 2, 3 ]
    }
}

Please note: shift() function won't return removed item

results matching ""

    No results matching ""