You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
615 B

4 years ago
  1. /**
  2. * This function is like `arrayIncludes` except that it accepts a comparator.
  3. *
  4. * @private
  5. * @param {Array} [array] The array to inspect.
  6. * @param {*} target The value to search for.
  7. * @param {Function} comparator The comparator invoked per element.
  8. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  9. */
  10. function arrayIncludesWith(array, value, comparator) {
  11. var index = -1,
  12. length = array == null ? 0 : array.length;
  13. while (++index < length) {
  14. if (comparator(value, array[index])) {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. module.exports = arrayIncludesWith;