Last active
March 5, 2020 16:43
-
-
Save mafintosh/b6db176225ea9ad927366419931ea445 to your computer and use it in GitHub Desktop.
Revisions
-
mafintosh revised this gist
Mar 5, 2020 . 1 changed file with 1 addition and 0 deletions.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 @@ -13,5 +13,6 @@ async function runQueue () { async function addToQueue (job) { pending.push(job) queue.notify() return done.wait() } -
mafintosh created this gist
Mar 5, 2020 .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,17 @@ const queue = new Signal() const done = new Signal() const pending = [] async function runQueue () { while (!pending.length && await queue.wait()); const current = pending pending = [] await process(current) done.notify() } async function addToQueue (job) { pending.push(job) return done.wait() }