immutable-data
Easily "set", "merge", "remove" nested objects and arrays in an immutable manner.
"immutable-data" lets you specify the part of the data you want to change, and then set the value, then it can change the part that you want to change, at the same time, the rest data that you do not want to change will not be affected.
api
set(data, map)
-
data: original data you want to change
-
map: the path map
'a.b.0': 1 // or 'a["b"][0]': 1
eg:
var set = set; var data = a: b: 2 c: d: 2 ; //return a: b: 1 c: d: 1
merge(data, object)
-
data: original data you want to change
-
object: deep merge object
eg:
var merge = merge; var data = a: b: 2 c: d: 2 ; //return a: b: 1 c: d: 1
Tip: If the type of a value is an array, it will be assigned a direct value.
//returnlist:0 //returnlist:02
remove(data, path)
-
data: original data you want to change
-
path: String or Array
"a.b""a.b""a.c"
eg:
var remove = remove; var data = a: b: 2 c: d: 2 ; // return a: {} c:
dev
$ npm install
$ npm run dev
$ npm test
$ npm run build
License
MIT License