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>`.
11 lines (10 loc) • 544 B
TypeScript
import type { RecoveryFn } from '../../internal/function.js';
import { type Maybe, type NotNullOrUndefined } from '../core/maybe.js';
/**
* Return _input_ as `T` if the passed _input_ is not `null` and `undefined`.
* Otherwise, return the result of _recoverer_.
*
* * The result of _recoverer_ must not be `Maybe<*>`.
* * If the result of _recoverer_ is `null` or `undefined`, throw `TypeError`.
*/
export declare function unwrapOrElseForMaybe<T>(input: Maybe<T>, recoverer: RecoveryFn<NotNullOrUndefined<T>>): NotNullOrUndefined<T>;