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

Function liftThrowable

packages/effect/src/UndefinedOr.ts:139–148  ·  view source on GitHub ↗
(
  f: (...a: A) => B
)

Source from the content-addressed store, hash-verified

137 * @since 4.0.0
138 */
139export const liftThrowable = <A extends ReadonlyArray<unknown>, B>(
140 f: (...a: A) => B
141): (...a: A) => B | undefined =>
142(...a) => {
143 try {
144 return f(...a)
145 } catch {
146 return undefined
147 }
148}
149
150/**
151 * Creates a `Reducer` for `UndefinedOr<A>` that prioritizes the first non-`undefined`

Callers

nothing calls this directly

Calls 1

fFunction · 0.50

Tested by

no test coverage detected