JSFiddle - React, Tailwind, and code Playground

by bladnman

JavaScript

/**
       * Clean up the contiguous item arrays
       *
       * We need to not double-request things that are already being requested. This
       * means looking through our itemArrays and trimming off bits.
       *
       * EXAMPLES
       *
       * (simple)
       *    contiguousItemArrays      [[1,2,3]]
       *    _rangesInFlight           [{offset:2, size:3}]   // offset is an index-start-point
       *    <- result                 [[1,2]]
       *
       *
       *  (complex)
       *    contiguousItemArrays      [[1,2], [3,4], [5,6]]
       *    _rangesInFlight           [{offset:1, size:2}, {offset:4, size:1}]
       *    <- result                 [[1], [4], [6]]
       *
       *
       * (only from edges, not middles)
       *    contiguousItemArrays      [[1,2,3,4,5,6]]
       *    _rangesInFlight           [{offset:2, size:3}]
       *    <- result                 [[1,2,3,4,5,6]]
       *
       *
       */
function main() {
  let contiguousItemArrays      = [[1,2,3]];
  let _rangesInFlight           = [{offset:2, size:3}];
  _removeInFlightRanges(contiguousItemArrays, _rangesInFlight);
}
function _removeInFlightRanges(contiguousItemArrays, _rangesInFlight) {
  console.log("contiguousItemArrays", contiguousItemArrays);
  console.log("_rangesInFlight", _rangesInFlight);
}
main();