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

Function processChunk

packages/effect/src/internal/stream.ts:2908–2938  ·  view source on GitHub ↗
(
    chunk: Chunk.Chunk<Exit.Exit<A, Option.Option<E2>>>,
    cont: Channel.Channel<Chunk.Chunk<A>, Chunk.Chunk<Exit.Exit<A, Option.Option<E2>>>, E | E2, E, unknown, unknown, R>
  )

Source from the content-addressed store, hash-verified

2906 self: Stream.Stream<Exit.Exit<A, Option.Option<E2>>, E, R>
2907): Stream.Stream<A, E | E2, R> => {
2908 const processChunk = (
2909 chunk: Chunk.Chunk<Exit.Exit<A, Option.Option<E2>>>,
2910 cont: Channel.Channel<Chunk.Chunk<A>, Chunk.Chunk<Exit.Exit<A, Option.Option<E2>>>, E | E2, E, unknown, unknown, R>
2911 ) => {
2912 const [toEmit, rest] = pipe(chunk, Chunk.splitWhere((exit) => !Exit.isSuccess(exit)))
2913 const next = pipe(
2914 Chunk.head(rest),
2915 Option.match({
2916 onNone: () => cont,
2917 onSome: Exit.match({
2918 onFailure: (cause) =>
2919 Option.match(Cause.flipCauseOption(cause), {
2920 onNone: () => core.void,
2921 onSome: core.failCause
2922 }),
2923 onSuccess: () => core.void
2924 })
2925 })
2926 )
2927 return pipe(
2928 core.write(pipe(
2929 toEmit,
2930 Chunk.filterMap((exit) =>
2931 Exit.isSuccess(exit) ?
2932 Option.some(exit.value) :
2933 Option.none()
2934 )
2935 )),
2936 core.flatMap(() => next)
2937 )
2938 }
2939 const process: Channel.Channel<
2940 Chunk.Chunk<A>,
2941 Chunk.Chunk<Exit.Exit<A, Option.Option<E2>>>,

Callers 1

flattenExitOptionFunction · 0.85

Calls 3

headMethod · 0.80
pipeFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected