function scanForUnloadedRanges(
    isItemLoaded,
    minimumBatchSize,
    items,
    totalItems,
    startIndex,
    stopIndex
  ) {
    if (isItemLoaded === void 0) {
      isItemLoaded = defaultIsItemLoaded
    }

    if (minimumBatchSize === void 0) {
      minimumBatchSize = 16
    }

    if (totalItems === void 0) {
      totalItems = 9e9
    }

    var unloadedRanges = []
    var 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) {
      var 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) {
      var firstUnloadedStart = unloadedRanges[0]
      var firstUnloadedStop = unloadedRanges[1]

      while (
        firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize &&
        firstUnloadedStart > 0
      ) {
        var _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,
    minimumBatchSize,
    items,
    totalItems,
    startIndex,
    stopIndex
  ) {
    if (isItemLoaded === void 0) {
      isItemLoaded = defaultIsItemLoaded
    }
    if (minimumBatchSize === void 0) {
      minimumBatchSize = 16
    }
    if (totalItems === void 0) {
      totalItems = 9e9
    }
    var unloadedRanges = []
    var 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) {
      var 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) {
      var firstUnloadedStart = unloadedRanges[0]
      var firstUnloadedStop = unloadedRanges[1]
      while (
        firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize &&
        firstUnloadedStart > 0
      ) {
        var _index = firstUnloadedStart - 1
        if (!isItemLoaded(_index, items)) {
          unloadedRanges[0] = firstUnloadedStart = _index
        } else {
          break
        }
      }
    }
    return unloadedRanges
  }
function scanForUnloadedRanges ( isItemLoaded , minimumBatchSize , items , totalItems , startIndex , stopIndex ) { if ( isItemLoaded === void 0 ) { isItemLoaded = defaultIsItemLoaded } if ( minimumBatchSize === void 0 ) { minimumBatchSize = 16 } if ( totalItems === void 0 ) { totalItems = 9e9 } var unloadedRanges = [ ] var 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 ) { var 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 ) { var firstUnloadedStart = unloadedRanges [ 0 ] var firstUnloadedStop = unloadedRanges [ 1 ] while ( firstUnloadedStop - firstUnloadedStart + 1 < minimumBatchSize && firstUnloadedStart > 0 ) { var _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 */