Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Latest commit

 

History

History
48 lines (29 loc) · 1.15 KB

Result.md

File metadata and controls

48 lines (29 loc) · 1.15 KB

MATTR Wallet SDK React Native / Exports / Result

Namespace: Result

Table of contents

Functions

Functions

fromThrowable

fromThrowable<Fn, E>(fn, errorFn?): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>

Wraps a function with a try catch, creating a new function with the same arguments but returning Ok if successful, Err if the function throws

Type parameters

Name Type
Fn extends (...args: readonly any[]) => any
E E

Parameters

Name Type Description
fn Fn function to wrap with ok on success or err on failure
errorFn? (e: unknown) => E when an error is thrown, this will wrap the error result if provided

Returns

fn

▸ (...args): Result<ReturnType<Fn>, E>

Parameters
Name Type
...args Parameters<Fn>
Returns

Result<ReturnType<Fn>, E>