MCPcopy Create free account
hub / github.com/Effect-TS/effect / runSequential

Function runSequential

packages/effect/src/internal/effect.ts:4703–4721  ·  view source on GitHub ↗
(
    state: S,
    items: ReadonlyArray<A>,
    index: number,
    end: number
  )

Source from the content-addressed store, hash-verified

4701 const step = options.step
4702
4703 const runSequential = (
4704 state: S,
4705 items: ReadonlyArray<A>,
4706 index: number,
4707 end: number
4708 ): Effect.Effect<void, E | E2, R> | undefined => {
4709 for (; index < end; index++) {
4710 const item = items[index]
4711 const effect = onItem(state, item, index)
4712 if (!effectIsExit(effect)) {
4713 return flatMap(
4714 exit(effect),
4715 (itemExit) => step(state, item, itemExit, index) ?? runSequential(state, items, index + 1, end) ?? void_
4716 )
4717 }
4718 const terminal = step(state, item, effect, index)
4719 if (terminal) return terminal._tag === "Failure" ? terminal : undefined
4720 }
4721 }
4722
4723 return (
4724 state: S,

Callers 1

effect.tsFile · 0.85

Calls 3

effectIsExitFunction · 0.85
onItemFunction · 0.70
stepFunction · 0.70

Tested by

no test coverage detected