SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 510 JavaScript
2015-12-16 17:53:20 -08:00
define([], function() {
/**
2016-02-29 23:38:21 -08:00
* This function is like `arrayIncludes` except that it accepts a comparator.
2015-12-16 17:53:20 -08:00
*
* @private
2016-08-11 23:27:31 -07:00
* @param {Array} [array] The array to inspect.
2015-12-16 17:53:20 -08:00
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
2016-10-30 20:06:57 -07:00
length = array == null ? 0 : array.length;
2015-12-16 17:53:20 -08:00
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
return arrayIncludesWith;
});