function scanForUnloadedRanges(
  isItemLoaded = defaultIsItemLoaded,
  minimumBatchSize = 16,
  items,
  totalItems = 9e9,
  startIndex,
  stopIndex
) {
  const unloadedRanges = []
  let rangeStartIndex,
    rangeStopIndex,
    index = startIndex
  /* istanbul ignore next */

  for (; index <= stopIndex; index++) {
    if (!isItemLoaded(index, items)) {
      rangeStopIndex = index
      if (rangeStartIndex === void 0) rangeStartIndex = index
    } else if (rangeStartIndex !== void 0 && rangeStopIndex !== void 0) {
      unloadedRanges.push(rangeStartIndex, rangeStopIndex)
      rangeStartIndex = rangeStopIndex = void 0
    }
  } // If :rangeStopIndex is not null it means we haven't run out of unloaded rows.
  // Scan forward to try filling our :minimumBatchSize.

  if (rangeStartIndex !== void 0 && rangeStopIndex !== void 0) {
    const potentialStopIndex = Math.min(
      Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1),
      totalItems - 1
    )
    /* istanbul ignore next */

    for (index = rangeStopIndex + 1; index <= potentialStopIndex; index++) {
      if (!isItemLoaded(index, items)) {
        rangeStopIndex = index
      } else {
        break
      }
    }

    unloadedRanges.push(rangeStartIndex, rangeStopIndex)
  } // Check to see if our first range ended prematurely.
  // In this case we should scan backwards to try filling our :minimumBatchSize.

  /* istanbul ignore next */

  if (unloadedRanges.length) {
    let firstUnloadedStart = unloadedRanges[0]
    const firstUnloadedStop = unloadedRanges[1]

    while (
      firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize &&
      firstUnloadedStart > 0
    ) {
      const index = firstUnloadedStart - 1

      if (!isItemLoaded(index, items)) {
        unloadedRanges[0] = firstUnloadedStart = index
      } else {
        break
      }
    }
  }

  return unloadedRanges
}
/**
 * Returns all of the ranges within a larger range that contain unloaded rows.
 */
Returns all of the ranges within a larger range that contain unloaded rows.
Returns all of the ranges within a larger range that contain unloaded rows .
function scanForUnloadedRanges(
  isItemLoaded = defaultIsItemLoaded,
  minimumBatchSize = 16,
  items,
  totalItems = 9e9,
  startIndex,
  stopIndex
) {
  const unloadedRanges = []
  let rangeStartIndex,
    rangeStopIndex,
    index = startIndex
  for (; index <= stopIndex; index++) {
    if (!isItemLoaded(index, items)) {
      rangeStopIndex = index
      if (rangeStartIndex === void 0) rangeStartIndex = index
    } else if (rangeStartIndex !== void 0 && rangeStopIndex !== void 0) {
      unloadedRanges.push(rangeStartIndex, rangeStopIndex)
      rangeStartIndex = rangeStopIndex = void 0
    }
  } 
  if (rangeStartIndex !== void 0 && rangeStopIndex !== void 0) {
    const potentialStopIndex = Math.min(
      Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1),
      totalItems - 1
    )
    for (index = rangeStopIndex + 1; index <= potentialStopIndex; index++) {
      if (!isItemLoaded(index, items)) {
        rangeStopIndex = index
      } else {
        break
      }
    }
    unloadedRanges.push(rangeStartIndex, rangeStopIndex)
  } 
  if (unloadedRanges.length) {
    let firstUnloadedStart = unloadedRanges[0]
    const firstUnloadedStop = unloadedRanges[1]
    while (
      firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize &&
      firstUnloadedStart > 0
    ) {
      const index = firstUnloadedStart - 1
      if (!isItemLoaded(index, items)) {
        unloadedRanges[0] = firstUnloadedStart = index
      } else {
        break
      }
    }
  }
  return unloadedRanges
}
function scanForUnloadedRanges ( isItemLoaded = defaultIsItemLoaded , minimumBatchSize = 16 , items , totalItems = 9e9 , startIndex , stopIndex ) { const unloadedRanges = [ ] let rangeStartIndex , rangeStopIndex , index = startIndex for ( ; index <= stopIndex ; index ++ ) { if ( ! isItemLoaded ( index , items ) ) { rangeStopIndex = index if ( rangeStartIndex === void 0 ) rangeStartIndex = index } else if ( rangeStartIndex !== void 0 && rangeStopIndex !== void 0 ) { unloadedRanges . push ( rangeStartIndex , rangeStopIndex ) rangeStartIndex = rangeStopIndex = void 0 } } if ( rangeStartIndex !== void 0 && rangeStopIndex !== void 0 ) { const potentialStopIndex = Math . min ( Math . max ( rangeStopIndex , rangeStartIndex + minimumBatchSize - 1 ) , totalItems - 1 ) for ( index = rangeStopIndex + 1 ; index <= potentialStopIndex ; index ++ ) { if ( ! isItemLoaded ( index , items ) ) { rangeStopIndex = index } else { break } } unloadedRanges . push ( rangeStartIndex , rangeStopIndex ) } if ( unloadedRanges . length ) { let firstUnloadedStart = unloadedRanges [ 0 ] const firstUnloadedStop = unloadedRanges [ 1 ] while ( firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize && firstUnloadedStart > 0 ) { const index = firstUnloadedStart - 1 if ( ! isItemLoaded ( index , items ) ) { unloadedRanges [ 0 ] = firstUnloadedStart = index } else { break } } } return unloadedRanges }
Returns all of the ranges within a larger range that contain unloaded rows.
Returns all of the ranges within a larger range that contain unloaded rows .
/* istanbul ignore next */ // If :rangeStopIndex is not null it means we haven't run out of unloaded rows. // Scan forward to try filling our :minimumBatchSize. /* istanbul ignore next */ // Check to see if our first range ended prematurely. // In this case we should scan backwards to try filling our :minimumBatchSize. /* istanbul ignore next */