UNPKG

zephyr-edge-contract

Version:

Edge contract for Zephyr

21 lines (20 loc) • 572 B
async function forEachLimit(tasks, batchSize) { const results = Array.from({ length: tasks.length }); let currentIndex = 0; async function worker() { while(currentIndex < tasks.length){ const taskIndex = currentIndex++; const task = tasks[taskIndex]; results[taskIndex] = await task(); } } const workers = Array.from({ length: batchSize }, ()=>worker()); await Promise.all(workers); return results; } export { forEachLimit }; //# sourceMappingURL=forEachLimit.mjs.map