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>`.
15 lines (14 loc) • 937 B
TypeScript
import type { AsyncTransformFn, AsyncRecoveryFn } from '../../internal/function.js';
import { type Maybe, type NotNullOrUndefined } from '../core/maybe.js';
/**
* Return the result of _transformer_ with using _input_ as an argument for it if _input_ is not `null` and `undefined`.
* Otherwise, return the result of _recoverer_.
*
* Basically, this operation is a combination `map()` and `unwrapOrElse()`.
*
* * `U` must not be `Maybe<*>`.
* * If the result of _transformer_ is `null` or `undefined`, this throw an `Error`.
* * If the result of _recoverer_ is `null` or `undefined`, this throw an `Error`.
* * If you'd like to accept `Maybe<*>` as `U`, use a combination `andThen()` and `orElse()`.
*/
export declare function mapOrElseAsyncForMaybe<T, U>(input: Maybe<T>, recoverer: AsyncRecoveryFn<NotNullOrUndefined<U>>, transformer: AsyncTransformFn<T, NotNullOrUndefined<U>>): Promise<NotNullOrUndefined<U>>;