UNPKG

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