@franki/x-diff
v1.0.1
Published
A light toolkit to diff Object.
Downloads
2
Maintainers
Readme
x-diff
x-diff is a light toolkit to diff two object
Support
- [x] diff simple object
- [x] diff simple array
- [x] diff object in array
- [x] diff complex object
- [x] diff complex array
Result
// use x-diff
import XDiff from 'x-diff'
const { diff } = new XDiff()
diff({ a: 1, c: 1, e: [{a: 1}] }, { a: 2, d: 1, e: [{b: 1}] })
// diff result
{
"before": {
"a": 1,
"c": 1,
"e": [
{
"a": 1,
"diff_a": "delete",
"diff_b": "delete"
}
],
"diff_c": "delete",
"diff_d": "delete",
"diff_a": "update",
"diff_e": "update"
},
"after": {
"a": 2,
"d": 1,
"e": [
{
"b": 1,
"diff_a": "add",
"diff_b": "add"
}
],
"diff_c": "add",
"diff_d": "add",
"diff_a": "update",
"diff_e": "update"
}
}