MCPcopy Create free account
hub / github.com/effect-app/libs / foldUntil

Function foldUntil

repos/effect/packages/effect/src/Sink.ts:798–809  ·  view source on GitHub ↗
(
  s: LazyArg<S>,
  max: number,
  f: (s: S, input: In) => Effect.Effect<S, E, R>
)

Source from the content-addressed store, hash-verified

796 * @category folding
797 * @since 4.0.0
798 */
799export 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 }

Callers

nothing calls this directly

Calls 5

foldFunction · 0.85
pipeMethod · 0.65
mapMethod · 0.65
fFunction · 0.50
mapFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…