lib/line-column.js
function findLowerIndexInRangeArray(value, arr) {
  if (value >= arr[arr.length - 1]) {
    return arr.length - 1;
  }

  var min = 0, max = arr.length - 2, mid;
  while (min < max) {
    mid = min + ((max - min) >> 1);

    if (value < arr[mid]) {
      max = mid - 1;
    } else if (value >= arr[mid + 1]) {
      min = mid + 1;
    } else { // value >= arr[mid] && value < arr[mid + 1]
      min = mid;
      break;
    }
  }
  return min;
}
function findLowerIndexInRangeArray(value, arr) {
  if (value >= arr[arr.length - 1]) {
    return arr.length - 1;
  }

  var min = 0, max = arr.length - 2, mid;
  while (min < max) {
    mid = min + ((max - min) >> 1);

    if (value < arr[mid]) {
      max = mid - 1;
    } else if (value >= arr[mid + 1]) {
      min = mid + 1;
    } else { // value >= arr[mid] && value < arr[mid + 1]
      min = mid;
      break;
    }
  }
  return min;
}
function findLowerIndexInRangeArray ( value , arr ) { if ( value >= arr [ arr . length - 1 ] ) { return arr . length - 1 ; } var min = 0 , max = arr . length - 2 , mid ; while ( min < max ) { mid = min + ( ( max - min ) >> 1 ) ; if ( value < arr [ mid ] ) { max = mid - 1 ; } else if ( value >= arr [ mid + 1 ] ) { min = mid + 1 ; } else { // value >= arr[mid] && value < arr[mid + 1] min = mid ; break ; } } return min ; }
Find a lower-bound index of a value in a sorted array of ranges.

Assume `arr = [0, 5, 10, 15, 20]` and
this returns `1` for `value = 7` (5 <= value < 10),
and returns `3` for `value = 18` (15 <= value < 20).

@private
@param  arr   {number[]} An array of values representing ranges.
@param  value {number}   A value to be searched.
@return {number} Found index. If not found `-1`.
Find a lower - bound index of a value in a sorted array of ranges .