2023年2月

const items = [
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2',
  'https://httpbin.org/bytes/2'
]

// get a cursor that keeps track of what items have already been processed.
let cursor = items.entries();

// create 5 for loops that each run off the same cursor which keeps track of location
Array(5).fill().forEach(async (item,idx) => {
    for (let [index, url] of cursor){
        console.log('getting url is ', index, url,idx)
        // run your async task instead of this next line
        var text = await fetch(url).then(res => res.text())
        console.log('text is', text.slice(0, 20))
    }
})
console.log("asdf")