feat: implémenter processBatch et downloadAllAsZip

This commit is contained in:
2026-05-27 10:06:57 +02:00
parent 3ff71b0ef9
commit 205faeede2
2 changed files with 35 additions and 2 deletions
+15 -1
View File
@@ -1,3 +1,17 @@
/**
* Traite un tableau d'items avec au plus `concurrency` appels simultanés.
* @param {any[]} items
* @param {(item: any) => Promise<void>} processFn
* @param {number} concurrency
* @returns {Promise<void>}
*/
export async function processBatch(items, processFn, concurrency = 3) {
throw new Error('Not implemented');
const queue = [...items];
const workers = Array.from({ length: concurrency }, async () => {
while (queue.length > 0) {
const item = queue.shift();
if (item !== undefined) await processFn(item);
}
});
await Promise.all(workers);
}