| 68 | const double = Stream.make(1, 2) |
| 69 | const failed = Stream.fail("Ouch") |
| 70 | const run = <E>(stream: Stream.Stream<number, E>) => |
| 71 | pipe( |
| 72 | Ref.make(Chunk.empty<number>()), |
| 73 | Effect.flatMap((ref) => |
| 74 | pipe( |
| 75 | stream, |
| 76 | Stream.transduce(Sink.foldEffect( |
| 77 | 0, |
| 78 | constTrue, |
| 79 | (_, y: number) => pipe(Ref.update(ref, Chunk.append(y)), Effect.as(30)) |
| 80 | )), |
| 81 | Stream.runCollect, |
| 82 | Effect.flatMap((exit) => |
| 83 | pipe( |
| 84 | Ref.get(ref), |
| 85 | Effect.map((result) => [Array.from(exit), Array.from(result)]) |
| 86 | ) |
| 87 | ) |
| 88 | ) |
| 89 | ), |
| 90 | Effect.exit |
| 91 | ) |
| 92 | const result1 = yield* run(empty) |
| 93 | const result2 = yield* run(single) |
| 94 | const result3 = yield* run(double) |