mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/binaryIndexBy'], function(baseCallback, binaryIndex, binaryIndexBy) {
|
|
|
|
/**
|
|
* This method is like `_.sortedIndex` except that it returns the highest
|
|
* index at which `value` should be inserted into `array` in order to
|
|
* maintain its sort order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The sorted array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `iteratee`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
* @example
|
|
*
|
|
* _.sortedLastIndex([4, 4, 5, 5], 5);
|
|
* // => 4
|
|
*/
|
|
function sortedLastIndex(array, value, iteratee, thisArg) {
|
|
return iteratee == null
|
|
? binaryIndex(array, value, true)
|
|
: binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1), true);
|
|
}
|
|
|
|
return sortedLastIndex;
|
|
});
|