( s: LazyArg<S>, max: number, f: (s: S, input: In) => Effect.Effect<S, E, R> )
| 796 | * @category folding |
| 797 | * @since 4.0.0 |
| 798 | */ |
| 799 | export const foldArray = <S, In, E = never, R = never>( |
| 800 | s: LazyArg<S>, |
| 801 | contFn: Predicate<S>, |
| 802 | f: (s: S, input: Arr.NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R> |
| 803 | ): Sink<S, In, never, E, R> => |
| 804 | fromTransform((upstream) => { |
| 805 | let state = s() |
| 806 | return Effect.gen(function*() { |
| 807 | while (true) { |
| 808 | const arr = yield* upstream |
| 809 | state = yield* f(state, arr) |
| 810 | if (contFn(state)) continue |
| 811 | return [state] as const |
| 812 | } |