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

Function firstSuccessOf

packages/effect/src/STM.ts:1983–1994  ·  view source on GitHub ↗
(effects: Iterable<STM<A, E, R>>)

Source from the content-addressed store, hash-verified

1981 * @category elements
1982 */
1983export const firstSuccessOf = <A, E, R>(effects: Iterable<STM<A, E, R>>): STM<A, E, R> =>
1984 suspend<A, E, R>(() => {
1985 const list = Chunk.fromIterable(effects)
1986 if (!Chunk.isNonEmpty(list)) {
1987 return dieSync(() => new Cause.IllegalArgumentException(`Received an empty collection of effects`))
1988 }
1989 return Chunk.reduce(
1990 Chunk.tailNonEmpty(list),
1991 Chunk.headNonEmpty(list),
1992 (left, right) => orElse(left, () => right)
1993 )
1994 })
1995
1996/**
1997 * @category do notation

Callers

nothing calls this directly

Calls 3

orElseFunction · 0.85
suspendFunction · 0.70
dieSyncFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…