option-t
Version:
A toolkit of Nullable/Option/Result type implementation in ECMAScript. Their APIs are inspired by Rust's `Option<T>` and `Result<T, E>`.
9 lines (8 loc) • 467 B
TypeScript
import type { AsyncRecoveryFn } from '../internal/function.js';
import { type Result } from '../plain_result/result.js';
import { type Maybe } from './maybe.js';
/**
* Transforms the `Maybe<T>` into a `Result<T, E>` by mapping `T` to `Ok(T)`.
* If `input` is `undefined` or `null`, then returns `Err(E)` with the result of `recoverer()`
*/
export declare function okOrElseAsyncForMaybe<T, E>(input: Maybe<T>, recoverer: AsyncRecoveryFn<E>): Promise<Result<T, E>>;