MCPcopy
hub / github.com/Effect-TS/effect / unfoldEffect

Function unfoldEffect

packages/effect/test/utils/unfoldEffect.ts:5–12  ·  view source on GitHub ↗
(
  s: S,
  f: (s: S) => Effect.Effect<Option.Option<readonly [A, S]>, E, R>
)

Source from the content-addressed store, hash-verified

3import * as Option from "effect/Option"
4
5export const unfoldEffect = <A, S, E, R>(
6 s: S,
7 f: (s: S) => Effect.Effect<Option.Option<readonly [A, S]>, E, R>
8): Effect.Effect<ReadonlyArray<A>, E, R> =>
9 Effect.map(
10 unfoldEffectLoop(s, f, List.empty()),
11 (list) => Array.from(List.reverse(list))
12 )
13
14const unfoldEffectLoop = <A, S, E, R>(
15 s: S,

Callers 2

racing.test.tsFile · 0.50
zipping.test.tsFile · 0.50

Calls 2

unfoldEffectLoopFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…