Skip to main content

Overview

The okAsync function constructs a ResultAsync containing an Ok variant with the provided value.

Signature

T
required
The success value to wrap in a ResultAsync
Returns: ResultAsync<T, E> - A ResultAsync containing the Ok value

Usage

Basic usage

Async context

Chaining operations

When to use

  • Starting an async operation that cannot fail
  • Converting a successful value into a ResultAsync for consistency
  • Creating test data with async operations
okAsync immediately wraps the value in a resolved Promise. For values that are already promises, use ResultAsync.fromSafePromise() instead.

errAsync

Create an Err variant of ResultAsync

ResultAsync.fromPromise

Create ResultAsync from a Promise