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

Function sortedIndex

underscore-node-f.cjs:1290–1299  ·  view source on GitHub ↗
(array, obj, iteratee, context)

Source from the content-addressed store, hash-verified

1288// Use a comparator function to figure out the smallest index at which
1289// an object should be inserted so as to maintain order. Uses binary search.
1290function sortedIndex(array, obj, iteratee, context) {
1291 iteratee = cb(iteratee, context, 1);
1292 var value = iteratee(obj);
1293 var low = 0, high = getLength(array);
1294 while (low < high) {
1295 var mid = Math.floor((low + high) / 2);
1296 if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
1297 }
1298 return low;
1299}
1300
1301// Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions.
1302function 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…