How to execute functions in parallel with async.js?

前端 未结 4 1999
忘了有多久
忘了有多久 2020-12-12 07:03

In the following code, I have Array.forEach, It executes the doSomething synchronous function in sequence:

items.forEach(function(i         


        
4条回答
  •  生来不讨喜
    2020-12-12 07:26

    You can only run those funcs in order (maybe this is what you need), for this use eachSeries function instead of each. Here is a short documentation for eachSeries:

    The same as each only the iterator is applied to each item in the array in series. The next iterator is only called once the current one has completed processing. This means the iterator functions will complete in order.

    Expression synchronous function in parallel - has no sence actually. Parallel means async execution.

提交回复
热议问题