Although the other answers are correct, since node.js now supports ES6, in my opinion, using the built-in Promise
library will be more stable and tidy.
You donβt even need to demand anything, Ecma took the library Promises / A + and implemented it in its own Javascript.
Promise.all(["one", "two","three"].map(processItem)) .then(function (results) {
Since Javascript is a rather problematic language (dynamic typing, asynchronous stream) when it comes to debugging, using Promise
instead of callbacks will save you time in the end.
source share