a360d3a75ceb9d20237f0fef396022bec2315cb8
[yaffs-website] / arrayIncludesWith.js
1 /**
2  * A specialized version of `_.includesWith` for arrays without support for
3  * specifying an index to search from.
4  *
5  * @private
6  * @param {Array} array The array to search.
7  * @param {*} target The value to search for.
8  * @param {Function} comparator The comparator invoked per element.
9  * @returns {boolean} Returns `true` if `target` is found, else `false`.
10  */
11 function arrayIncludesWith(array, value, comparator) {
12   var index = -1,
13       length = array.length;
14
15   while (++index < length) {
16     if (comparator(value, array[index])) {
17       return true;
18     }
19   }
20   return false;
21 }
22
23 module.exports = arrayIncludesWith;