DT
http://bluebirdjs.com/docs/api/promise.map.html
Size: a a a
DT
H
H
UT
UT
H
АК
АК
Promise.map()
из bluebird
-аA
АК
АК
A
АК
A
АК
АК
АК
concurrency
и в самой очереди функций будет не больше concurrency
. на скорую руку, но суть, думаю, понятна:const LINKS = [/* ... */];
const concurrency = 5;
const queue = new Queue({ concurrency });
async function task(link) {
// const res = await got(link);
// await saveResult(link, res);
await delay(1000);
}
let LAST_IDX = 0;
const runTask = async () => {
const link = LINKS[LAST_IDX];
if (!link) return;
LAST_IDX += 1;
await task(link);
queue.add(() => runTask());
};
for (let idx = 0; idx < concurrency; idx++) {
queue.add(() => runTask());
}
D
TS