UNPKG

overlaps

Version:

Simple utility that checks whether or not two arrays overlap. It is equivalent to intersection(arr1, arr2).length > 0, but is more performant.

9 lines (8 loc) 219 B
module.exports = function(arr1, arr2, cmp) { cmp = cmp || function(a, b) { return a === b; }; return arr1.some(function(item) { return arr2.some(function(item2) { return cmp(item, item2); }); }); };