()
| 80 | } |
| 81 | |
| 82 | dequeue(): RunFunction | undefined { |
| 83 | if (this.#head === this.#queue.length) { |
| 84 | return undefined; |
| 85 | } |
| 86 | |
| 87 | const item = this.#queue[this.#head]; |
| 88 | this.#head++; |
| 89 | |
| 90 | if (this.#head === this.#queue.length) { |
| 91 | // Fully drained queues are reset immediately so the next enqueue starts from a clean array. |
| 92 | this.#queue.length = 0; |
| 93 | this.#head = 0; |
| 94 | } else if (this.#head > compactionThreshold && this.#head > this.#queue.length / 2) { |
| 95 | // Keep repeated dequeues cheap, but stop the consumed prefix from growing without bound. |
| 96 | this.#compact(); |
| 97 | } |
| 98 | |
| 99 | return item?.run; |
| 100 | } |
| 101 | |
| 102 | filter(options: Readonly<Partial<PriorityQueueOptions>>): RunFunction[] { |
| 103 | const result: RunFunction[] = []; |
no test coverage detected