dashboard/dashboard/spa/timeseries-cache-request.js
function findLowIndexInSortedArray(ary, getKey, loVal) {
  if (ary.length === 0) return 1;

  let low = 0;
  let high = ary.length - 1;
  let i;
  let comparison;
  let hitPos = -1;
  while (low <= high) {
    i = Math.floor((low + high) / 2);
    comparison = getKey(ary[i]) - loVal;
    if (comparison < 0) {
      low = i + 1; continue;
    } else if (comparison > 0) {
      high = i - 1; continue;
    } else {
      hitPos = i;
      high = i - 1;
    }
  }
  // return where we hit, or failing that the low pos
  return hitPos !== -1 ? hitPos : low;
}
function findLowIndexInSortedArray(ary, getKey, loVal) {
  if (ary.length === 0) return 1;

  let low = 0;
  let high = ary.length - 1;
  let i;
  let comparison;
  let hitPos = -1;
  while (low <= high) {
    i = Math.floor((low + high) / 2);
    comparison = getKey(ary[i]) - loVal;
    if (comparison < 0) {
      low = i + 1; continue;
    } else if (comparison > 0) {
      high = i - 1; continue;
    } else {
      hitPos = i;
      high = i - 1;
    }
  }
  // return where we hit, or failing that the low pos
  return hitPos !== -1 ? hitPos : low;
}
function findLowIndexInSortedArray ( ary , getKey , loVal ) { if ( ary . length === 0 ) return 1 ; let low = 0 ; let high = ary . length - 1 ; let i ; let comparison ; let hitPos = - 1 ; while ( low <= high ) { i = Math . floor ( ( low + high ) / 2 ) ; comparison = getKey ( ary [ i ] ) - loVal ; if ( comparison < 0 ) { low = i + 1 ; continue ; } else if ( comparison > 0 ) { high = i - 1 ; continue ; } else { hitPos = i ; high = i - 1 ; } } // return where we hit, or failing that the low pos return hitPos !== - 1 ? hitPos : low ; }
Finds the first index in the array whose value is >= loVal.

The key for the search is defined by the getKey. This array must
be prearranged such that ary.map(getKey) would also be sorted in
ascending order.

@param {Array} ary An array of arbitrary objects.
@param {function():*} getKey Callback that produces a key value
from an element in ary.
@param {number} loVal Value for which to search.
@return {Number} Offset o into ary where all ary[i] for i <= o
are < loVal, or ary.length if loVal is greater than all elements in
the array.
Finds the first index in the array whose value is > = loVal .