/
dany
/
ReshenijaBotInformationSite
Обзор
Документация
Войти
/
dany
/
ReshenijaBotInformationSite
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
node_modules/underscore/amd/_binarySearch.js
17 строк
537 B
Daniil
Initial commit
31 окт 2023, 01:10
31 окт 2023, 01:10
a171ae1
Код
Авторство
О чём код?
define(['./_getLength'], function (_getLength) { // Iteratively cut `array` in half to figure out the index at which `obj` should // be inserted so as to maintain the order defined by `compare`. function binarySearch(array, obj, iteratee, compare) { var value = iteratee(obj); var low = 0, high = _getLength(array); while (low < high) { var mid = Math.floor((low + high) / 2); if (compare(iteratee(array[mid]), value)) low = mid + 1; else high = mid; } return low; } return binarySearch; });