array-merges
v0.1.0
Published
Merge arrays under strategy
Downloads
8
Readme
array-merge
Merge arrays under strategy
Example
var merge = require('array-merges');
var arr = merge([{a: 1}], [{a: 1}], {
equal: function(prev, next) {
return prev.a === next.a;
},
onMerge: function(prev, next) {
return [prev, next];
}
});
console.log(arr); // [{a: 1}, {a: 1}]
Options
- options.equal: Function used to make comparation. Default is
function (prev, next) {
return prev === next;
}
- options.onMerge: Hook that determines the merge result between two elements that are judged as equal. Default is
function(prev, next) {
return [prev]; // abandon dulicate element
}
Lisence
MIT