Skip to content

Function.fromPromise

GitHub Actions edited this page Mar 5, 2025 · 27 revisions

resultar / fromPromise

Function: fromPromise()

fromPromise<T, E>(promise, errorFn): ResultAsync<T, E>

Defined in: result-async.ts:470

Returns a ResultAsync instance that is resolved with a Result.ok(value) or Result.err(error) based on the provided promise.

Type Parameters

T

E

Parameters

promise

PromiseLike<T>

The promise to be wrapped in a ResultAsync.

errorFn

(e) => E

A function that transforms the error from the promise into the error type E.

Returns

ResultAsync<T, E>

A ResultAsync instance with the given promise and error type E.

Clone this wiki locally