let someArray = [1, 2]
let chunkSize = 10
let chunks = chunk(someArray, chunkSize)const chunk = (a, l) => a.length === 0 ? [] : [a.slice(0, l)].concat(chunk(a.slice(l), l));It runs batches synchronously, but async for each item in a batch
let batches = chunk(myArray, 10)
for(let batch of batches){
await Promise.all(batch.map(async(item) => {
await doSomeAsyncStuffForEachItemInBatch(item);
}));
})