diff-array-objs

1.0.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i diff-array-objs

    Weekly Downloads

    4

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • alessioalex