get-diff
Installation
npm install get-diff --save
Syntax
Usage
Diff a shallow object
; const userA = username: 'Max';const userB = username: 'Jane'; // [// {// keyPath: 'username',// values: ['Max','Jane'],// types: ['isSTRING','isSTRING']// }// ]
Diff a deep object
; const userA = work: 'title': 'Developer' ; const userB = work: {}; // [// {// keyPath: 'work.title',// values: ['Developer', undefined],// types: ['isSTRING','isUNDEFINED']// }// ]
Diff everything...
; const genderFemale = Symbol'female'; const userA = userId: 1 firstname: 'Maxine' surname: 'Mustermann' age: 20 sex: genderFemale level: Symbol'admin' hobbies: 'golf' 'tennis' music: 'Blur' work: title: 'Developer' senior: 'yes' cool: false happy: true birthDath: '1984-01-01' recentLogin: '2015-01-01'; const userB = userId: 2 firstname: 'Maxine' surname: 'Johansson' age: 20 sex: genderFemale level: Symbol'admin' hobbies: 'golf' 'tennis' music: 'Pulp' work: title: 'Developer' senior: 'no' cool: false happy: true birthDath: '1984-01-01' recentLogin: '2015-01-02'; // [{// keyPath: 'userId',// values: [1, 2],// types: ['isNUMBER', 'isNUMBER']// }, {// keyPath: 'surname',// values: ['Mustermann', 'Johansson'],// types: ['isSTRING', 'isSTRING']// }, {// keyPath: 'level',// values: [{}, {}],// types: ['isSYMBOL', 'isSYMBOL']// }, {// keyPath: 'music.0',// values: ['Blur', 'Pulp'],// types: ['isSTRING', 'isSTRING']// }, {// keyPath: 'work.senior',// values: ['yes', 'no'],// types: ['isSTRING', 'isSTRING']// }, {// keyPath: 'recentLogin',// values: [Thu Jan 01 2015 01: 00: 00 GMT + 0100(CET),// Fri Jan 02 2015 01: 00: 00 GMT + 0100(CET)// ],// types: ['isDATE', 'isDATE']// }]
Tests
npm test
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
Release History
- 0.0.3 Fixed date bug
- 0.0.2 Date support
- 0.0.1 Initial alpha release