merge
Merge immutable JSON data structures to allow for identity (===) comparisons on
deeply-equal subtrees.
Installation
npm i @broofa/merge
Example
const assert = require('assert');
const merge = require('@broofa/merge');
const obj0 = {
a: 'hello',
b: 123,
c: {
ca: 'zig',
cb: [{a:1}, {b:2}]
},
};
const obj1 = {
a: 'world',
c: {
ca: {a: 1},
cb: [{a:99}, {b:2}]
},
};
const result = merge(obj0, obj1);
assert.deepEqual(obj1, result);
result.c === obj0.c;
result.c.ca === obj0.c.ca;
result.c.cb === obj0.c.cb;
result.c.cb[0] === obj0.c.cb[0];
result.c.cb[1] === obj0.c.cb[1];
Markdown generated from src/README_js.md by ![RunMD Logo](http://i.imgur.com/h0FVyzU.png)