a zip code crypto-currency system good for red ONLY

sortedIndexOf.js 762B

1234567891011121314151617181920212223242526272829303132
  1. var baseSortedIndex = require('./_baseSortedIndex'),
  2. eq = require('./eq');
  3. /**
  4. * This method is like `_.indexOf` except that it performs a binary
  5. * search on a sorted `array`.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @since 4.0.0
  10. * @category Array
  11. * @param {Array} array The array to inspect.
  12. * @param {*} value The value to search for.
  13. * @returns {number} Returns the index of the matched value, else `-1`.
  14. * @example
  15. *
  16. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  17. * // => 1
  18. */
  19. function sortedIndexOf(array, value) {
  20. var length = array == null ? 0 : array.length;
  21. if (length) {
  22. var index = baseSortedIndex(array, value);
  23. if (index < length && eq(array[index], value)) {
  24. return index;
  25. }
  26. }
  27. return -1;
  28. }
  29. module.exports = sortedIndexOf;