// *** before: ***
function processAll(promises) {
var i = 0;
function next() {
if (i >= promises.length) return;
promises[i++].then(function (value) {
console.log(value);
next();
});
}
next();
}
// *** in version ES2018: ***
async function processAll(asyncIterable) {
for await (const value of asyncIterable) {
console.log(value);
}
}