2.0.1 • Published 1 year ago
objecdiff v2.0.1
An object difference library for NodeJS
This module can compares two objects and return the key that has changed along with the original and updated values.
Installation
$ npm install objecdiffUsage
const objecdiff = require('objecdiff');
// Alternatively:
import { diff } from 'objecdiff';API
diff(original, updated) Documentation
objecdiff.diff(objectA, objectB)
// Alternatively if using the `import` method shown above:
diff(objectA, objectB)objectA-Object- The original or first object that you would like to compare.objectB-Object- The updated or second object that you would like to compare the first against.
Example
import { diff } from 'objecdiff';
let a = {
firstName: 'Mike',
lastName: 'R',
city: 'Boston'
},
b = {
firstName: 'Dan',
name: 'Dan G',
color: {
favorite: 'blue'
},
city: 'Boston'
};
console.log(diff(a, b));
// => [ { path: 'firstName', original: 'Mike', updated: 'Dan' },
// => { path: 'lastName', original: 'R', updated: undefined },
// => { path: 'name', original: undefined, updated: 'Dan G' },
// => { path: 'color.favorite', original: null, updated: 'blue' } ]Tests
$ npm testTo see test coverage, please run:
$ npm run coverageFeatures
- Natively supports nested documents
- Compares the objects and returns the key that has changed along with the original and updated values
2.0.1
1 year ago
2.0.0
3 years ago
1.2.5
4 years ago
1.2.4
4 years ago
1.2.3
4 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.6
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
7 years ago
1.0.2
8 years ago
1.0.1
9 years ago
1.0.0
9 years ago
0.0.1
9 years ago