object-array-merge
v1.0.1
Published
Merges Object Arrays based on an object key, A.K.A: Tom’s Merge
Downloads
2
Maintainers
Readme
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} ];