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

Function buffering

packages/effect/src/internal/stream.ts:721–735  ·  view source on GitHub ↗
(
        acc: Chunk.Chunk<A>
      )

Source from the content-addressed store, hash-verified

719 ) =>
720 suspend(() => {
721 const buffering = (
722 acc: Chunk.Chunk<A>
723 ): Channel.Channel<Chunk.Chunk<A2>, Chunk.Chunk<A>, E2, never, unknown, unknown, R | R2> =>
724 core.readWith({
725 onInput: (input) => {
726 const nextSize = acc.length + input.length
727 if (nextSize >= n) {
728 const [b1, b2] = pipe(input, Chunk.splitAt(n - acc.length))
729 return running(pipe(acc, Chunk.appendAll(b1)), b2)
730 }
731 return buffering(pipe(acc, Chunk.appendAll(input)))
732 },
733 onFailure: core.fail,
734 onDone: () => running(acc, Chunk.empty())
735 })
736 const running = (
737 prefix: Chunk.Chunk<A>,
738 leftover: Chunk.Chunk<A>

Callers 1

stream.tsFile · 0.85

Calls 2

pipeFunction · 0.70
runningFunction · 0.70

Tested by

no test coverage detected