( s: LazyArg<S>, contFn: Predicate<S>, f: (s: S, input: Arr.NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R> )
| 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 | } |
| 813 | }).pipe( |
| 814 | Pull.catchDone(() => Effect.succeed<End<S>>([state])) |
| 815 | ) |
| 816 | }) |
| 817 | |
| 818 | /** |
| 819 | * Folds input elements into state until the specified maximum number of |
nothing calls this directly
no test coverage detected