j
Size: a a a
j
j
GH
j
Р
const delay = (res, ms) => new Promise((resolve) => setTimeout(resolve, ms, res));
let arr = [
() => delay(5000, 5000),
() => delay(3000, 3000),
() => delay(2000, 2000),
]
async function promisesInSeries(asyncFns) {
for (const item of asyncFns) {
await item().then(data => {
console.log(data);
return data
});
}
}
promisesInSeries(arr);
М
j
j
j
j
Р
В
В
j
Р
1
В
j
async function promisesInSeries (functions) {
if (!functions) {
return Promise.resolve(undefined)
} else {
return Promise.all(functions.map(func => func()))
}
}