MCPcopy
hub / github.com/jashkenas/underscore / sortedIndex

Function sortedIndex

underscore.js:1297–1306  ·  view source on GitHub ↗
(array, obj, iteratee, context)

Source from the content-addressed store, hash-verified

1295 // Use a comparator function to figure out the smallest index at which
1296 // an object should be inserted so as to maintain order. Uses binary search.
1297 function sortedIndex(array, obj, iteratee, context) {
1298 iteratee = cb(iteratee, context, 1);
1299 var value = iteratee(obj);
1300 var low = 0, high = getLength(array);
1301 while (low < high) {
1302 var mid = Math.floor((low + high) / 2);
1303 if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
1304 }
1305 return low;
1306 }
1307
1308 // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
1309 function createIndexFinder(dir, predicateFind, sortedIndex) {

Callers 1

createIndexFinderFunction · 0.70

Calls 2

cbFunction · 0.70
iterateeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…