okAsync()
okAsync<
T,E>(value):ResultAsync<T,E>
Creates a new successful async result.
This function wraps a value in a successful ResultAsync. If you need to wrap
a Promise, use fromSafePromise or fromPromise instead.
Type Parametersโ
T: Tโ
The type of the success value
E: E = neverโ
The type of the error value (defaults to never)
Parametersโ
value: Tโ
The value to wrap
Returns: ResultAsync<T, E>โ
A new ResultAsync that will resolve to Ok(value)
Sinceโ
2.0.0
Exampleโ
// With direct value
const direct = okAsync(42);
const resolved = await direct; // Ok(42)
// For Promises, use fromSafePromise or fromPromise
const promise = Promise.resolve("hello");
const async = ResultAsync.fromSafePromise(promise);
const result = await async; // Ok("hello")