object-array-merge

1.0.1 • Public • Published

object-array-merge

Merges two arrays of objects based on a provided key.

The default operation is to merge the two arrays with the left hand side (a) taking precedence without mutating the original object.

var a = [
  { id: 2, b: 2, c: 1 }
];
 
var b = [
  { id: 2, b: 7 },
];
 
merge(a, b, 'a');
// output = [ {id: 2, b: 2, c: 1} ];
// this is an alias to merge.left
 
merge.left(a, b, 'a');
// output = [ {id: 2, b: 2, c: 1} ];
 
merge.right(a, b, 'a');
// output = [ {id: 2, b: 7, c: 1} ];

License ISC

Package Sidebar

Install

npm i object-array-merge

Weekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • tomgco