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>`.

9 lines (8 loc) 480 B
import type { RecoveryFn } from '../../internal/function.js'; import { type Result } from '../../plain_result/core/result.js'; import { type Undefinable } from '../core/undefinable.js'; /** * Transforms the `Undefinable<T>` into a `Result<T, E>` by mapping `T` to `Ok(T)`. * If `input` is `undefined`, then returns `Err(E)` with the result of `recoverer()` */ export declare function okOrElseForUndefinable<T, E>(input: Undefinable<T>, recoverer: RecoveryFn<E>): Result<T, E>;