| 828 | * @since 2.0.0 |
| 829 | */ |
| 830 | export const foldUntil = <S, In, E = never, R = never>( |
| 831 | s: LazyArg<S>, |
| 832 | max: number, |
| 833 | f: (s: S, input: In) => Effect.Effect<S, E, R> |
| 834 | ): Sink<S, In, In, E, R> => |
| 835 | fold<readonly [S, number], In, E, R>( |
| 836 | () => [s(), 0], |
| 837 | (tuple) => tuple[1] < max, |
| 838 | ([output, count], input) => Effect.map(f(output, input), (s) => [s, count + 1] as const) |
| 839 | ).pipe( |
| 840 | map((tuple) => tuple[0]) |
| 841 | ) |
| 842 | |
| 843 | /** |
| 844 | * A sink that returns whether all elements satisfy the specified predicate. |