sortedIndex.js 626 B

12345678910111213141516171819202122232425
  1. var baseSortedIndex = require('./_baseSortedIndex');
  2. /**
  3. * Uses a binary search to determine the lowest index at which `value`
  4. * should be inserted into `array` in order to maintain its sort order.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 0.1.0
  9. * @category Array
  10. * @param {Array} array The sorted array to inspect.
  11. * @param {*} value The value to evaluate.
  12. * @returns {number} Returns the index at which `value` should be inserted
  13. * into `array`.
  14. * @example
  15. *
  16. * _.sortedIndex([30, 50], 40);
  17. * // => 1
  18. */
  19. function sortedIndex(array, value) {
  20. return baseSortedIndex(array, value);
  21. }
  22. module.exports = sortedIndex;