UNPKG

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) 646 B
import type { TransformFn } 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 `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 mapForMaybe<T, U>(input: Maybe<T>, transformer: TransformFn<T, NotNullOrUndefined<U>>): Maybe<U>;