Skip to content Skip to sidebar Skip to footer

Elegant Way To Call A Callback Function After Other Callbacks Returned

I have the following code in my nodejs application: function someFileOperation(callback) { var files = ...; files.forEach(function (file) { doSomethingAsync(file, f

Solution 1:

Use async.map or async.foreach see here: https://github.com/caolan/async#map and https://github.com/caolan/async#forEach

the async.map method takes an array of items and performs the same async call for each item in your array in parallel. If no errors are encountered, it will call a callback with a new array of results.

Post a Comment for "Elegant Way To Call A Callback Function After Other Callbacks Returned"