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

Function foldChunkSplitEffectInternal

packages/effect/src/internal/sink.ts:1028–1047  ·  view source on GitHub ↗
(
  s: S,
  chunk: Chunk.Chunk<In>,
  index: number,
  length: number,
  contFn: Predicate<S>,
  f: (s: S, input: In) => Effect.Effect<S, E, R>
)

Source from the content-addressed store, hash-verified

1026
1027/** @internal */
1028const foldChunkSplitEffectInternal = <S, R, E, In>(
1029 s: S,
1030 chunk: Chunk.Chunk<In>,
1031 index: number,
1032 length: number,
1033 contFn: Predicate<S>,
1034 f: (s: S, input: In) => Effect.Effect<S, E, R>
1035): Effect.Effect<[S, Option.Option<Chunk.Chunk<In>>], E, R> => {
1036 if (index === length) {
1037 return Effect.succeed([s, Option.none()])
1038 }
1039 return pipe(
1040 f(s, pipe(chunk, Chunk.unsafeGet(index))),
1041 Effect.flatMap((s1) =>
1042 contFn(s1) ?
1043 foldChunkSplitEffectInternal(s1, chunk, index + 1, length, contFn, f) :
1044 Effect.succeed([s1, Option.some(pipe(chunk, Chunk.drop(index + 1)))])
1045 )
1046 )
1047}
1048
1049/** @internal */
1050export const foldLeft = <S, In>(s: S, f: (s: S, input: In) => S): Sink.Sink<S, In> =>

Callers 1

foldChunkSplitEffectFunction · 0.85

Calls 3

unsafeGetMethod · 0.80
pipeFunction · 0.70
fFunction · 0.50

Tested by

no test coverage detected