Skip to content

Commit 0f08fb9

Browse files
committed
Clear from queue immidiately
1 parent 8ad6ae4 commit 0f08fb9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/queue.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ function Queue() {
1111
push: (x) => xs.push(x),
1212
peek: () => xs[index],
1313
shift: () => {
14+
const out = xs[index++]
15+
1416
if (index === xs.length) {
15-
index = -1
17+
index = 0
1618
xs = []
17-
} else if (index > 0) {
19+
} else {
1820
xs[index - 1] = undefined
1921
}
2022

21-
return xs[index++]
23+
return out
2224
}
2325
}
2426
}

0 commit comments

Comments
 (0)