1.0.0 • Published 8 years ago

diff-array-objs v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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