MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / binaryIndexBy

Function binaryIndexBy

lib/web/jshint.js:4380–4407  ·  view source on GitHub ↗

* This function is like `binaryIndex` except that it invokes `iteratee` for * `value` and each element of `array` to compute their sort ranking. The * iteratee is invoked with one argument; (value). * * @private * @param {Array} array The sorted array to inspect. * @par

(array, value, iteratee, retHighest)

Source from the content-addressed store, hash-verified

4378 * into `array`.
4379 */
4380 function binaryIndexBy(array, value, iteratee, retHighest) {
4381 value = iteratee(value);
4382
4383 var low = 0,
4384 high = array ? array.length : 0,
4385 valIsNaN = value !== value,
4386 valIsUndef = value === undefined;
4387
4388 while (low < high) {
4389 var mid = floor((low + high) / 2),
4390 computed = iteratee(array[mid]),
4391 isReflexive = computed === computed;
4392
4393 if (valIsNaN) {
4394 var setLow = isReflexive || retHighest;
4395 } else if (valIsUndef) {
4396 setLow = isReflexive && (retHighest || computed !== undefined);
4397 } else {
4398 setLow = retHighest ? (computed <= value) : (computed < value);
4399 }
4400 if (setLow) {
4401 low = mid + 1;
4402 } else {
4403 high = mid;
4404 }
4405 }
4406 return nativeMin(high, MAX_ARRAY_INDEX);
4407 }
4408
4409 /**
4410 * A specialized version of `baseCallback` which only supports `this` binding

Callers 2

binaryIndexFunction · 0.85
createSortedIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected