diff --git a/index.js b/index.js index fb64559..70c0980 100644 --- a/index.js +++ b/index.js @@ -41,8 +41,13 @@ export default class Queue { return; } - this.#head = this.#head.next; - this.#size--; + const next = current.next; + if (next) { + this.#head = next; + this.#size--; + } else { + this.clear(); + } return current.value; }