(
context: Context.Context<R>,
stream: Stream.Stream<Uint8Array | string, E, R>
)
| 516 | private fiber: Fiber.Fiber<void, E> | undefined = undefined |
| 517 | |
| 518 | constructor( |
| 519 | context: Context.Context<R>, |
| 520 | stream: Stream.Stream<Uint8Array | string, E, R> |
| 521 | ) { |
| 522 | super({}) |
| 523 | this.readLatch = Latch.makeUnsafe(false) |
| 524 | this.fiber = Stream.runForEachArray(stream, (chunk) => |
| 525 | this.readLatch.whenOpen(Effect.sync(() => { |
| 526 | this.readLatch.closeUnsafe() |
| 527 | for (let i = 0; i < chunk.length; i++) { |
| 528 | const item = chunk[i] |
| 529 | if (typeof item === "string") { |
| 530 | this.push(item, "utf8") |
| 531 | } else { |
| 532 | this.push(item) |
| 533 | } |
| 534 | } |
| 535 | }))).pipe( |
| 536 | this.readLatch.whenOpen, |
| 537 | Effect.provideContext(context), |
| 538 | Effect.runFork |
| 539 | ) |
| 540 | this.fiber.addObserver((exit) => { |
| 541 | this.fiber = undefined |
| 542 | if (Exit.isSuccess(exit)) { |
| 543 | this.push(null) |
| 544 | } else { |
| 545 | this.destroy(Cause.squash(exit.cause) as any) |
| 546 | } |
| 547 | }) |
| 548 | } |
| 549 | |
| 550 | override _read(_size: number): void { |
| 551 | this.readLatch.openUnsafe() |
nothing calls this directly
no test coverage detected