Ohm-Management - Projektarbeit B-ME
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.

sortedIndexBy.js 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. var baseIteratee = require('./_baseIteratee'),
  2. baseSortedIndexBy = require('./_baseSortedIndexBy');
  3. /**
  4. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  5. * which is invoked for `value` and each element of `array` to compute their
  6. * sort ranking. The iteratee is invoked with one argument: (value).
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.0.0
  11. * @category Array
  12. * @param {Array} array The sorted array to inspect.
  13. * @param {*} value The value to evaluate.
  14. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  15. * @returns {number} Returns the index at which `value` should be inserted
  16. * into `array`.
  17. * @example
  18. *
  19. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  20. *
  21. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  22. * // => 0
  23. *
  24. * // The `_.property` iteratee shorthand.
  25. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  26. * // => 0
  27. */
  28. function sortedIndexBy(array, value, iteratee) {
  29. return baseSortedIndexBy(array, value, baseIteratee(iteratee, 2));
  30. }
  31. module.exports = sortedIndexBy;