Skip to content

Diff two arrays of objects based on a specific property.

License

Notifications You must be signed in to change notification settings

alessioalex/diff-array-objs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diff-array-objs

Diff two arrays of objects based on a specific property.

Build Status

usage

diffArrayObjs(firstArray, secondArray, property, shouldReturnCommon)

example

var diffArrayObjsByProp = require('./');

var a = [{
  a: 1, b: 2, c: 3, id: 0
}, {
  a: 1, b: 3, c: 3, id: 1
}, {
  a: 1, b: 3, c: 9, id: 2
}];

var b = [{
  a: 1, b: 2, c: 3, id: 0
}, {
  a: 1, b: 3, c: 3, id: 1
}, {
  a: 1, b: 3, c: 9, id: 3
}];

console.log(diffArrayObjsByProp(a, b, 'id'));
//
// Sample output:
//
// { added: [ { a: 1, b: 3, c: 9, id: 3 } ],
//   removed: [ { a: 1, b: 3, c: 9, id: 2 } ] }

tests

npm test

license

MIT

About

Diff two arrays of objects based on a specific property.

Resources

License

Stars

Watchers

Forks

Packages

No packages published