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

Function split

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

Source from the content-addressed store, hash-verified

6360 predicate: Predicate<A>
6361 ): Stream.Stream<Chunk.Chunk<A>, E, R> => {
6362 const split = (
6363 leftovers: Chunk.Chunk<A>,
6364 input: Chunk.Chunk<A>
6365 ): Channel.Channel<Chunk.Chunk<Chunk.Chunk<A>>, Chunk.Chunk<A>, E, E, unknown, unknown, R> => {
6366 const [chunk, remaining] = pipe(leftovers, Chunk.appendAll(input), Chunk.splitWhere(predicate))
6367 if (Chunk.isEmpty(chunk) || Chunk.isEmpty(remaining)) {
6368 return loop(pipe(chunk, Chunk.appendAll(pipe(remaining, Chunk.drop(1)))))
6369 }
6370 return pipe(
6371 core.write(Chunk.of(chunk)),
6372 core.flatMap(() => split(Chunk.empty(), pipe(remaining, Chunk.drop(1))))
6373 )
6374 }
6375 const loop = (
6376 leftovers: Chunk.Chunk<A>
6377 ): 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