(reason)
| 223 | } |
| 224 | |
| 225 | cancel(reason) { |
| 226 | if (this.#cancelled) return; |
| 227 | this.#cancelled = true; |
| 228 | |
| 229 | if (reason !== undefined) { |
| 230 | this.#sourceError = reason; |
| 231 | } |
| 232 | |
| 233 | if (this.#sourceIterator?.return) { |
| 234 | PromisePrototypeThen(this.#sourceIterator.return(), undefined, () => {}); |
| 235 | } |
| 236 | |
| 237 | for (const consumer of this.#consumers) { |
| 238 | if (consumer.resolve) { |
| 239 | if (reason !== undefined) { |
| 240 | consumer.reject?.(reason); |
| 241 | } else { |
| 242 | consumer.resolve({ __proto__: null, done: true, value: undefined }); |
| 243 | } |
| 244 | consumer.resolve = null; |
| 245 | consumer.reject = null; |
| 246 | } |
| 247 | consumer.detached = true; |
| 248 | } |
| 249 | this.#consumers.clear(); |
| 250 | |
| 251 | for (let i = 0; i < this.#pullWaiters.length; i++) { |
| 252 | this.#pullWaiters[i](); |
| 253 | } |
| 254 | this.#pullWaiters = []; |
| 255 | } |
| 256 | |
| 257 | [SymbolDispose]() { |
| 258 | this.cancel(); |
no test coverage detected