( s: S, contFn: Predicate<S>, f: (s: S, input: In) => Effect.Effect<S, E, R> )
| 989 | |
| 990 | /** @internal */ |
| 991 | const foldEffectReader = <S, In, R, E>( |
| 992 | s: S, |
| 993 | contFn: Predicate<S>, |
| 994 | f: (s: S, input: In) => Effect.Effect<S, E, R> |
| 995 | ): Channel.Channel<Chunk.Chunk<In>, Chunk.Chunk<In>, E, E, S, unknown, R> => { |
| 996 | if (!contFn(s)) { |
| 997 | return core.succeedNow(s) |
| 998 | } |
| 999 | return core.readWith({ |
| 1000 | onInput: (input: Chunk.Chunk<In>) => |
| 1001 | pipe( |
| 1002 | core.fromEffect(foldChunkSplitEffect(s, input, contFn, f)), |
| 1003 | core.flatMap(([nextS, leftovers]) => |
| 1004 | pipe( |
| 1005 | leftovers, |
| 1006 | Option.match({ |
| 1007 | onNone: () => foldEffectReader(nextS, contFn, f), |
| 1008 | onSome: (leftover) => pipe(core.write(leftover), channel.as(nextS)) |
| 1009 | }) |
| 1010 | ) |
| 1011 | ) |
| 1012 | ), |
| 1013 | onFailure: core.fail, |
| 1014 | onDone: () => core.succeedNow(s) |
| 1015 | }) |
| 1016 | } |
| 1017 | |
| 1018 | /** @internal */ |
| 1019 | const foldChunkSplitEffect = <S, R, E, In>( |
no test coverage detected