From 2cadf871e57104c64e3017d83d5e4c01d768392b Mon Sep 17 00:00:00 2001 From: Mikhail Korotin Date: Fri, 15 Nov 2024 02:03:28 +0100 Subject: [PATCH] feat: use concurrency more effectively --- run-groups/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/run-groups/src/index.ts b/run-groups/src/index.ts index bbf3977a..b4dd5c1f 100644 --- a/run-groups/src/index.ts +++ b/run-groups/src/index.ts @@ -2,7 +2,9 @@ import pLimit = require('p-limit') export default async (concurrency: number, groups: (() => Promise)[][]) => { const limitRun = pLimit(concurrency) + const promises = []; for (const tasks of groups) { - await Promise.all(tasks.map((task) => limitRun(task))) + promisess.push(...tasks.map((task) => limitRun(task)))) } + await Promise.all(promises) }