Diff javascript
Why I another library to diff object
I knew there are already many libraries dealing with comparing two objects, like the below.
However, none of them support compare arrays with order insensitive, like [1, 2]
and [2, 1]
should be equal if we want to compare them with order insensitive.
Also this package support the following features other libraries didn't support like:
- certain path level configuration
- path level configuration with regex supported
- support arrays with order insensitive
- wrote in typescript
How to use it
Installation
npm i deep-diff-obj
Usage
- compare two primitives
diff1, 2 // [{ path: '', type: 'E', left: 1, right: 2 }]
- compare two simple objects
diff, // [{ path: 'a', left: 1, right: 2, type: 'E' }]
- compare two arrays (order sensitive)
diff, // [ { path: '[2]', type: 'A', right: 3 } ]
-- compare two array (order insensitive)
diff, , // []diff, , // [{ path: '(3)', type: 'A', right: 3 }]
If diff array with order insensitive, the path is the key surrounded by
()
- compare two object array: order insensitive, ignore undefined key (by default)
diff , , // []
- compare two object array: order insensitive, ignore undefined key
diff , , // [{ path: '(undefined)', type: 'D', left: { noid: 3 } }]
- ignore certain path
diff, , // []
- ignore certain path by regex
diff, , // []
See more examples in the unit tests
Plans
- setup project
- setup semantic-release
- setup npm package
- setup travis ci
Logs
- 20/11 2h
- 21/11 10m
- 22/11 20m
- 23/11 2h
- 26/11 20h