MCPcopy Create free account
hub / github.com/Effect-TS/effect / accumulator

Function accumulator

packages/effect/src/internal/stream.ts:106–119  ·  view source on GitHub ↗
(
    s: Chunk.Chunk<A>
  )

Source from the content-addressed store, hash-verified

104/** @internal */
105export const accumulateChunks = <A, E, R>(self: Stream.Stream<A, E, R>): Stream.Stream<A, E, R> => {
106 const accumulator = (
107 s: Chunk.Chunk<A>
108 ): Channel.Channel<Chunk.Chunk<A>, Chunk.Chunk<A>, E, E, void, unknown> =>
109 core.readWith({
110 onInput: (input: Chunk.Chunk<A>) => {
111 const next = Chunk.appendAll(s, input)
112 return core.flatMap(
113 core.write(next),
114 () => accumulator(next)
115 )
116 },
117 onFailure: core.fail,
118 onDone: () => core.void
119 })
120 return new StreamImpl(core.pipeTo(toChannel(self), accumulator(Chunk.empty())))
121}
122

Callers 2

accumulateChunksFunction · 0.85
stream.tsFile · 0.85

Calls 5

pipeFunction · 0.70
emitFunction · 0.70
writeMethod · 0.65
failMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected