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) 553 B
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 return `Err(E)` with passed `err`. * * Arguments passed to this are eagerly evaluated; * if you are passing the result of a function call, it is recommended to use okOrElse, * which is lazily evaluated. */ export declare function okOrForUndefinable<T, E>(input: Undefinable<T>, err: E): Result<T, E>;