ES6 Promise replacement of async.eachLimit / async.mapLimit

前端 未结 4 1045
南方客
南方客 2020-12-03 22:54

In async, if I need to apply a asynchronousfunction to 1000 items, I can do that with:

async.mapLimit(items, 10, (item, callback) => {
    foo(item, callb         


        
4条回答
  •  日久生厌
    2020-12-03 23:05

    Using Array.prototype.splice

    while (funcs.length) {
      await Promise.all( funcs.splice(0, 100).map(f => f()) )
    }
    

提交回复
热议问题