removeN(object, path, n) ⇒ 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 first item to be removed (array of items or dot-separated string can be provided) - n
number- number of items to remove
Description
import { removeN } from 'immutable-object-update';
const state = {
a: {
b: [ 1, 2, 3, 4, 5, 6 ]
},
};
const updated = removeN(state, [ 'a', 'b', 1 ], 3);
// or
const updated = removeN(state, 'b.b1.1', 3);
As a result we will receive new object with structure below:
{
a: {
b: [ 1, 5, 6 ]
}
}
Please note:
removeN()function won't return removed items