method AsyncResult.lift
AsyncResult.lift<T, E extends BaseError>(value: Result<T, E> | AsyncResult<T, E> | Promise<Result<T, E>>): AsyncResult<T, E>

Creates an AsyncResult from a Result, AsyncResult, or Promise<Result>.

This is the key method for working with MaybeAsync types - it normalizes both synchronous Results and asynchronous AsyncResults into AsyncResults.

Examples

Example 1

const asyncResult = AsyncResult.lift(Result.ok(42));
const asyncResult2 = AsyncResult.lift(Promise.resolve(Result.ok(42)));
const asyncResult3 = AsyncResult.lift(existingAsyncResult); // Pass-through

Type Parameters

The type of the success value

E extends BaseError

The type of the error

Parameters

value: Result<T, E> | AsyncResult<T, E> | Promise<Result<T, E>>

A Result, AsyncResult, or Promise<Result>

Return Type

An AsyncResult

Usage

import { AsyncResult } from "result/mod.ts";