| 939 | |
| 940 | /** @internal */ |
| 941 | const foldChunksReader = <S, In>( |
| 942 | s: S, |
| 943 | contFn: Predicate<S>, |
| 944 | f: (s: S, chunk: Chunk.Chunk<In>) => S |
| 945 | ): Channel.Channel<never, Chunk.Chunk<In>, never, never, S, unknown> => { |
| 946 | if (!contFn(s)) { |
| 947 | return core.succeedNow(s) |
| 948 | } |
| 949 | return core.readWith({ |
| 950 | onInput: (input: Chunk.Chunk<In>) => foldChunksReader(f(s, input), contFn, f), |
| 951 | onFailure: core.fail, |
| 952 | onDone: () => core.succeedNow(s) |
| 953 | }) |
| 954 | } |
| 955 | |
| 956 | /** @internal */ |
| 957 | export const foldChunksEffect = <S, In, E, R>( |