arr-and
v1.0.0
Published
Generic array and. Supports predicate equals function.
Downloads
3
Readme
Array AND
Generic array and function which supports equals predicate function.
Install
npm install arr-and
Usage
var and = require('arr-and');
and([1, 2], [2, 3]);
//=> [2]
and([1, 2, 3], [2, 3, 4], [3, 4, 5]);
//=> [3]
and([{id: 1}, {id: 2}], [{id: 2}, {id: 3}], function equals(a, b) {
return a.id === b.id;
});
//=> [{id: 2}]
API
and(...arrays, [equalsPredicate])
Creates an array of unique values that is the logical conjuction of the provided arrays.
...arrays
Required
Type: array
Two or more arrays to do AND operation.
equalsPredicate
Type: function
Default: function(a, b) { return a === b; }
Equality function. Should return true if a
and b
items are equal.
License
MIT