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

Function liftThrowable

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

Source from the content-addressed store, hash-verified

143 * @since 4.0.0
144 */
145export const liftThrowable = <A extends ReadonlyArray<unknown>, B>(
146 f: (...a: A) => B
147): (...a: A) => B | undefined =>
148(...a) => {
149 try {
150 return f(...a)
151 } catch {
152 return undefined
153 }
154}
155
156/**
157 * 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