Skip to content

fx-flow v0.7.0 / flow / toTry

Function: toTry()

toTry<A>(fn): (...args) => TryDoResult<ReturnType<A>>

Convert fn to (...args) => tryDo(() => fn(...args))

Type parameters

A extends AnyFunction

Parameters

fn: A

Returns

Function

Parameters

• ...args: Parameters<A>

Returns

TryDoResult<ReturnType<A>>

Example

typescript
const obj = {}
toTry(() => obj.a.b)() // get a failure Result

More examples

Source

packages/core/src/flow/toTry.ts:15

Released under the MIT License.