Last active
December 25, 2023 19:42
-
-
Save dtipson/e8184db4924cd532567ecfb8456d89d8 to your computer and use it in GitHub Desktop.
Revisions
-
dtipson revised this gist
Dec 25, 2023 . No changes.There are no files selected for viewing
-
dtipson created this gist
Dec 25, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ export async function* batchTasks(tasks = [], limit = 5, taskCallback = r => r) { for (let i = 0; i < tasks.length; i = i + limit) { const batch = tasks.slice(i, i + limit) yield* await Promise.all( batch.map((task) => task().then(taskCallback)) ) } }