Skip to content

Commit

Permalink
improve ThroatQueueFunction api
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Nov 29, 2022
1 parent 2bbf5ad commit 2bd71b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/ThroatQueueFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ function ThroatQueueFunction(n = 5){
const running = []
const ret = async function(what){
if(what === null){
if(running.length === 0) return
if(running.length === 0) return running
await Promise.all(running)
return
return running
}

// This shouldn't happen if we correctly await on the throat
Expand Down Expand Up @@ -37,6 +37,7 @@ function ThroatQueueFunction(n = 5){
const idObj = {}
const r = rFn()
r.id = idObj
r.fn = what
running.push(r)
await r

Expand Down

0 comments on commit 2bd71b3

Please sign in to comment.