(
context: Context.Context<R>,
stream: Stream.Stream<Uint8Array | string, E, R>
)
| 402 | private fiber: Fiber.Fiber<void, E> | undefined = undefined |
| 403 | |
| 404 | constructor( |
| 405 | context: Context.Context<R>, |
| 406 | stream: Stream.Stream<Uint8Array | string, E, R> |
| 407 | ) { |
| 408 | super({}) |
| 409 | this.readLatch = Latch.makeUnsafe(false) |
| 410 | this.fiber = Stream.runForEachArray(stream, (chunk) => |
| 411 | this.readLatch.whenOpen(Effect.sync(() => { |
| 412 | this.readLatch.closeUnsafe() |
| 413 | for (let i = 0; i < chunk.length; i++) { |
| 414 | const item = chunk[i] |
| 415 | if (typeof item === "string") { |
| 416 | this.push(item, "utf8") |
| 417 | } else { |
| 418 | this.push(item) |
| 419 | } |
| 420 | } |
| 421 | }))).pipe( |
| 422 | this.readLatch.whenOpen, |
| 423 | Effect.provideContext(context), |
| 424 | Effect.runFork |
| 425 | ) |
| 426 | this.fiber.addObserver((exit) => { |
| 427 | this.fiber = undefined |
| 428 | if (Exit.isSuccess(exit)) { |
| 429 | this.push(null) |
| 430 | } else { |
| 431 | this.destroy(Cause.squash(exit.cause) as any) |
| 432 | } |
| 433 | }) |
| 434 | } |
| 435 | |
| 436 | override _read(_size: number): void { |
| 437 | this.readLatch.openUnsafe() |
nothing calls this directly
no test coverage detected