Skip to content

Commit

Permalink
Clear from queue immidiately
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Dec 26, 2019
1 parent 8ad6ae4 commit 0f08fb9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ function Queue() {
push: (x) => xs.push(x),
peek: () => xs[index],
shift: () => {
const out = xs[index++]

if (index === xs.length) {
index = -1
index = 0
xs = []
} else if (index > 0) {
} else {
xs[index - 1] = undefined
}

return xs[index++]
return out
}
}
}

0 comments on commit 0f08fb9

Please sign in to comment.