function binarySearchFirstItem(items, condition) {
  var minIndex = 0;
  var maxIndex = items.length - 1;

  if (items.length === 0 || !condition(items[maxIndex])) {
    return items.length;
  }
  if (condition(items[minIndex])) {
    return minIndex;
  }

  while (minIndex < maxIndex) {
    var currentIndex = (minIndex + maxIndex) >> 1;
    var currentItem = items[currentIndex];
    if (condition(currentItem)) {
      maxIndex = currentIndex;
    } else {
      minIndex = currentIndex + 1;
    }
  }
  return minIndex; /* === maxIndex */
}
/**
 * Use binary search to find the index of the first item in a given array which
 * passes a given condition. The items are expected to be sorted in the sense
 * that if the condition is true for one item in the array, then it is also true
 * for all following items.
 *
 * @returns {Number} Index of the first array element to pass the test,
 *                   or |items.length| if no such element exists.
 */
Use binary search to find the index of the first item in a given array which
passes a given condition. The items are expected to be sorted in the sense
that if the condition is true for one item in the array, then it is also true
for all following items.

@returns {Number} Index of the first array element to pass the test,
or |items.length| if no such element exists.
Use binary search to find the index of the first item in a given array which passes a given condition . The items are expected to be sorted in the sense that if the condition is true for one item in the array then it is also true for all following items . @returns { Number } Index of the first array element to pass the test or |items . length| if no such element exists .
function binarySearchFirstItem(items, condition) {
  var minIndex = 0;
  var maxIndex = items.length - 1;
  if (items.length === 0 || !condition(items[maxIndex])) {
    return items.length;
  }
  if (condition(items[minIndex])) {
    return minIndex;
  }
  while (minIndex < maxIndex) {
    var currentIndex = (minIndex + maxIndex) >> 1;
    var currentItem = items[currentIndex];
    if (condition(currentItem)) {
      maxIndex = currentIndex;
    } else {
      minIndex = currentIndex + 1;
    }
  }
  return minIndex; 
}
function binarySearchFirstItem ( items , condition ) { var minIndex = 0 ; var maxIndex = items . length - 1 ; if ( items . length === 0 || ! condition ( items [ maxIndex ] ) ) { return items . length ; } if ( condition ( items [ minIndex ] ) ) { return minIndex ; } while ( minIndex < maxIndex ) { var currentIndex = ( minIndex + maxIndex ) >> 1 ; var currentItem = items [ currentIndex ] ; if ( condition ( currentItem ) ) { maxIndex = currentIndex ; } else { minIndex = currentIndex + 1 ; } } return minIndex ; }
Use binary search to find the index of the first item in a given array which
 passes a given condition.
Use binary search to find the index of the first item in a given array which passes a given condition .
/* === maxIndex */