* @description - Removes the value at the front of the queue * @returns {*} - The first data of the queue
()
| 45 | * @returns {*} - The first data of the queue |
| 46 | */ |
| 47 | dequeue() { |
| 48 | if (this.isEmpty()) { |
| 49 | throw new Error('Queue is Empty') |
| 50 | } |
| 51 | |
| 52 | const firstData = this.peekFirst() |
| 53 | |
| 54 | this.head = this.head.next |
| 55 | |
| 56 | if (!this.head) { |
| 57 | this.tail = null |
| 58 | } |
| 59 | |
| 60 | this.#size-- |
| 61 | |
| 62 | return firstData |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @description - Return the item at the front of the queue |
no test coverage detected