(value: T)
| 120 | } |
| 121 | |
| 122 | push(value: T): void { |
| 123 | // If an element has been requested while the stack was empty, indicate |
| 124 | // that an element has been restored |
| 125 | if (this.#queue.length > 0) { |
| 126 | const d = this.#queue.shift()!; |
| 127 | d.resolve(value); |
| 128 | } else { |
| 129 | this.#elements.push(value); |
| 130 | } |
| 131 | } |
| 132 | } |