2diff 中文文档教程
Node.js object difference
2diff
Instalation
npm i -S 2diff
Usage
const diff = require('2diff');
const before = {c: 3, a: 1, b: '2', e: {x: 9}};
const after = {a: 1, b: 1, e: {x: 9}, f: {x: 9}};
const result = diff(before, after);
console.log(result);
输出:
[
{ removed: true, key: 'c', value: 3 },
{ removed: true, key: 'b', value: '2' },
{ added: true, key: 'b', value: 1 },
{ added: true, key: 'f.x', value: 9 }
]
Node.js object difference
2diff
Instalation
npm i -S 2diff
Usage
const diff = require('2diff');
const before = {c: 3, a: 1, b: '2', e: {x: 9}};
const after = {a: 1, b: 1, e: {x: 9}, f: {x: 9}};
const result = diff(before, after);
console.log(result);
Output:
[
{ removed: true, key: 'c', value: 3 },
{ removed: true, key: 'b', value: '2' },
{ added: true, key: 'b', value: 1 },
{ added: true, key: 'f.x', value: 9 }
]