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>`.
12 lines (11 loc) • 661 B
TypeScript
import type { AsyncTransformFn } from '../internal/function.js';
import { type Maybe, type NotNullOrUndefined } from './maybe.js';
/**
* Return the result of _transformer_ with using _input_ as an argument for it if _input_ is not `null` and `undefined`.
* Otherwise, return `null` or `undefined` inputted as _input_.
*
* * `U` must not be `Maybe<*>`.
* * If you'd like return `Maybe<*>` as `U`, use `andThen()`.
* * If the result of _transformer_ is `null` or `undefined`, this throw an `Error`.
*/
export declare function mapAsyncForMaybe<T, U>(input: Maybe<T>, transformer: AsyncTransformFn<T, NotNullOrUndefined<U>>): Promise<Maybe<U>>;