5604448837690b4d8471fb86d2465224ff9d96f5
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / sortedLastIndexOf.js
1 var baseSortedIndex = require('./_baseSortedIndex'),
2     eq = require('./eq');
3
4 /**
5  * This method is like `_.lastIndexOf` except that it performs a binary
6  * search on a sorted `array`.
7  *
8  * @static
9  * @memberOf _
10  * @category Array
11  * @param {Array} array The array to search.
12  * @param {*} value The value to search for.
13  * @returns {number} Returns the index of the matched value, else `-1`.
14  * @example
15  *
16  * _.sortedLastIndexOf([1, 1, 2, 2], 2);
17  * // => 3
18  */
19 function sortedLastIndexOf(array, value) {
20   var length = array ? array.length : 0;
21   if (length) {
22     var index = baseSortedIndex(array, value, true) - 1;
23     if (eq(array[index], value)) {
24       return index;
25     }
26   }
27   return -1;
28 }
29
30 module.exports = sortedLastIndexOf;