Skip to content

Commit 3a212a4

Browse files
committed
avoid race condition in pop, close #10
1 parent ded92d4 commit 3a212a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export default class TinyQueue {
2121

2222
const top = this.data[0];
2323
const bottom = this.data.pop();
24+
this.length--;
2425

25-
if (this.length > 1) {
26+
if (this.length > 0) {
2627
this.data[0] = bottom;
2728
this._down(0);
2829
}
29-
this.length--;
3030

3131
return top;
3232
}

0 commit comments

Comments
 (0)