( s: S, contFn: Predicate<S>, f: (z: S, input: In) => S )
| 816 | |
| 817 | /** @internal */ |
| 818 | const foldReader = <S, In>( |
| 819 | s: S, |
| 820 | contFn: Predicate<S>, |
| 821 | f: (z: S, input: In) => S |
| 822 | ): Channel.Channel<Chunk.Chunk<In>, Chunk.Chunk<In>, never, never, S, unknown> => { |
| 823 | if (!contFn(s)) { |
| 824 | return core.succeedNow(s) |
| 825 | } |
| 826 | return core.readWith({ |
| 827 | onInput: (input: Chunk.Chunk<In>) => { |
| 828 | const [nextS, leftovers] = foldChunkSplit(s, input, contFn, f, 0, input.length) |
| 829 | if (Chunk.isNonEmpty(leftovers)) { |
| 830 | return pipe(core.write(leftovers), channel.as(nextS)) |
| 831 | } |
| 832 | return foldReader(nextS, contFn, f) |
| 833 | }, |
| 834 | onFailure: core.fail, |
| 835 | onDone: () => core.succeedNow(s) |
| 836 | }) |
| 837 | } |
| 838 | |
| 839 | /** @internal */ |
| 840 | const foldChunkSplit = <S, In>( |
no test coverage detected