MCPcopy Index your code
hub / github.com/Effect-TS/effect / split

Function split

packages/effect/src/internal/stream.ts:6324–6336  ·  view source on GitHub ↗
(
      leftovers: Chunk.Chunk<A>,
      input: Chunk.Chunk<A>
    )

Source from the content-addressed store, hash-verified

6322 predicate: Predicate<A>
6323 ): Stream.Stream<Chunk.Chunk<A>, E, R> => {
6324 const split = (
6325 leftovers: Chunk.Chunk<A>,
6326 input: Chunk.Chunk<A>
6327 ): Channel.Channel<Chunk.Chunk<Chunk.Chunk<A>>, Chunk.Chunk<A>, E, E, unknown, unknown, R> => {
6328 const [chunk, remaining] = pipe(leftovers, Chunk.appendAll(input), Chunk.splitWhere(predicate))
6329 if (Chunk.isEmpty(chunk) || Chunk.isEmpty(remaining)) {
6330 return loop(pipe(chunk, Chunk.appendAll(pipe(remaining, Chunk.drop(1)))))
6331 }
6332 return pipe(
6333 core.write(Chunk.of(chunk)),
6334 core.flatMap(() => split(Chunk.empty(), pipe(remaining, Chunk.drop(1))))
6335 )
6336 }
6337 const loop = (
6338 leftovers: Chunk.Chunk<A>
6339 ): Channel.Channel<Chunk.Chunk<Chunk.Chunk<A>>, Chunk.Chunk<A>, E, E, unknown, unknown, R> =>

Callers 1

loopFunction · 0.70

Calls 5

pipeFunction · 0.70
loopFunction · 0.70
isEmptyMethod · 0.65
writeMethod · 0.65
ofMethod · 0.65

Tested by

no test coverage detected