( s: S, contFn: Predicate<S>, f: (s: S, chunk: Chunk.Chunk<In>) => Effect.Effect<S, E, R> )
| 962 | |
| 963 | /** @internal */ |
| 964 | const foldChunksEffectReader = <S, R, E, In>( |
| 965 | s: S, |
| 966 | contFn: Predicate<S>, |
| 967 | f: (s: S, chunk: Chunk.Chunk<In>) => Effect.Effect<S, E, R> |
| 968 | ): Channel.Channel<never, Chunk.Chunk<In>, E, E, S, unknown, R> => { |
| 969 | if (!contFn(s)) { |
| 970 | return core.succeedNow(s) |
| 971 | } |
| 972 | return core.readWith({ |
| 973 | onInput: (input: Chunk.Chunk<In>) => |
| 974 | pipe( |
| 975 | core.fromEffect(f(s, input)), |
| 976 | core.flatMap((s) => foldChunksEffectReader(s, contFn, f)) |
| 977 | ), |
| 978 | onFailure: core.fail, |
| 979 | onDone: () => core.succeedNow(s) |
| 980 | }) |
| 981 | } |
| 982 | |
| 983 | /** @internal */ |
| 984 | export const foldEffect = <S, In, E, R>( |
no test coverage detected