MCPcopy
hub / github.com/Effect-TS/effect / run

Function run

packages/effect/test/Sink/folding.test.ts:70–91  ·  view source on GitHub ↗
(stream: Stream.Stream<number, E>)

Source from the content-addressed store, hash-verified

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)

Callers 1

folding.test.tsFile · 0.70

Calls 5

makeMethod · 0.65
updateMethod · 0.65
getMethod · 0.65
mapMethod · 0.65
pipeFunction · 0.50

Tested by

no test coverage detected