This package has been deprecated

Author message:

use lodash-fp instead

immutate

0.1.0 • Public • Published

Immutate

Immitating Immutable Mutations - Functional mutations for deep data structures

Install

npm install --save immutate

Usage

Just import the module:

import immutate from 'immutate';

...or if you only want one of the functions:

import deepDelete from 'immutate/lib/deepDelete';

API

deepDelete({a: {b: {c: 'c'}}}, ['a', 'b', 'c']);
// => {a: {b: {}}},
deepGet({a: {b: {c: 'c'}}}, ['a', 'b', 'c']);
// => 'c'
deepPop({a: {b: {c: [1, 2, 3]}}}, ['a', 'b', 'c']);
// => {a: {b: {c: [1, 2]}}}
deepPush({a: {b: {c: [1, 2, 3]}}}, ['a', 'b', 'c'], 4, 5, 6);
// => {a: {b: {c: [1, 2, 3, 4, 5, 6]}}}
deepReplace({a: {b: {c: 'sea'}}}, ['a', 'b', 'c'], /a/, 'e');
// => {a: {b: {c: 'see'}}}
deepSet({a: {b: {c: 'c'}}}, ['a', 'b', 'c'], 'is for cookie');
// => {a: {b: {c: 'is for cookie'}}}
deepShift({a: {b: {c: [1, 2, 3]}}}, ['a', 'b', 'c']);
// => {a: {b: {c: [2, 3]}}}
deepSlice({a: {b: {c: [1, 2, 3]}}}, 1);
// => [2, 3]
deepSort({a: {b: {c: [2, 3, 1]}}});
// => {a: {b: {c: [1, 2, 3]}}}
deepSplice({a: {b: {c: [0, 1, 2, 3]}}}, 1, 2, 'one', 'two');
// => {a: {b: {c: [0, 'one', 'two', 3]}}}
 
deepTransform({a: {b: {c: 'c'}}}, ['a', 'b', 'c'], (value) => value.toUpperCase());
// => {a: {b: {c: 'C'}}}
deepUnshift({a: {b: {c: [1, 2, 3]}}}, ['a', 'b', 'c'], -2, -1, 0);
// => {a: {b: {c: [-2, -1, 0, 1, 2, 3]}}}

Readme

Keywords

none

Package Sidebar

Install

npm i immutate

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • spudly