()
| 465 | } |
| 466 | |
| 467 | #resolvePendingReads() { |
| 468 | while (this.#pendingReads.length > 0) { |
| 469 | if (this.#slots.length > 0) { |
| 470 | const pending = this.#pendingReads.shift(); |
| 471 | const result = this.#drain(); |
| 472 | this.#resolvePendingWrites(); |
| 473 | pending.resolve({ __proto__: null, done: false, value: result }); |
| 474 | } else if (this.#writerState === 'closing' && this.#slots.length === 0) { |
| 475 | this.endDrained(); |
| 476 | const pending = this.#pendingReads.shift(); |
| 477 | pending.resolve({ __proto__: null, done: true, value: undefined }); |
| 478 | } else if (this.#writerState === 'closed') { |
| 479 | const pending = this.#pendingReads.shift(); |
| 480 | pending.resolve({ __proto__: null, done: true, value: undefined }); |
| 481 | } else if (this.#writerState === 'errored') { |
| 482 | const pending = this.#pendingReads.shift(); |
| 483 | pending.reject(this.#error); |
| 484 | } else if (this.#consumerState === 'returned') { |
| 485 | const pending = this.#pendingReads.shift(); |
| 486 | pending.resolve({ __proto__: null, done: true, value: undefined }); |
| 487 | } else { |
| 488 | break; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | #resolvePendingWrites() { |
| 494 | while (this.#pendingWrites.length > 0 && |
no test coverage detected