( s: LazyArg<S>, contFn: Predicate<S>, f: (s: S, input: Arr.NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R> )
| 828 | * @since 4.0.0 |
| 829 | */ |
| 830 | export const foldArray = <S, In, E = never, R = never>( |
| 831 | s: LazyArg<S>, |
| 832 | contFn: Predicate<S>, |
| 833 | f: (s: S, input: Arr.NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R> |
| 834 | ): Sink<S, In, never, E, R> => |
| 835 | fromTransform((upstream) => { |
| 836 | let state = s() |
| 837 | return Effect.gen(function*() { |
| 838 | while (true) { |
| 839 | const arr = yield* upstream |
| 840 | state = yield* f(state, arr) |
| 841 | if (contFn(state)) continue |
| 842 | return [state] as const |
| 843 | } |
| 844 | }).pipe( |
| 845 | Pull.catchDone(() => Effect.succeed<End<S>>([state])) |
| 846 | ) |
| 847 | }) |
| 848 | |
| 849 | /** |
| 850 | * Folds input elements into state until the specified maximum number of |
nothing calls this directly
no test coverage detected