1.3.6 • Published 9 years ago

immutable-obj v1.3.6

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Regarding Issues

tool to access an obj and return a new one which share the common part

Installation

Use npm.

npm install --save-dev immutable-obj

API

var update = require('immutable-obj');
/*
obj // {}
path //array which define a scope for the changing part,the rest will be shared
value //if path exist alter the path value  else create the path then define the value
*/
var newObj = update(obj,path,value);

update.isEqual(obj,newObj);//check if value is equal,meant for react rerender check

#usage

var a = {
    province: {
        address: {
            zone: 'A',
            info : {
                lastName : 'ze'
            }
        }
    },
    c: {
        x: [1,2,3],
        y: [1,{name'liu'},3,4]
    }
};

var b = update(a, ['province','address','zone'], 'B');

console.log('a',a,'\n' ,'b',b,'\n', b.province.address.info === a.province.address.info);

var c = update(a, 'province.address.zone', 'C');

console.log('a',a,'\n' ,'c',c,'\n');

var d = update(a, ['c','y',1], {name:'liu'});

console.log(a,d,a==d,isEqual(a,d));//false  true
1.3.6

9 years ago

1.3.5

9 years ago

1.3.4

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago