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

20 lines (19 loc) 761 B
import { type Nullable } from '../nullable/nullable.js'; import { type Undefinable } from '../undefinable/undefinable.js'; import { type Result } from './result.js'; /** * Transposes a `Result` of an `Nullable<T>` into an `Nullable<T>` of a `Result`. * * - `Ok(T)` -> `Ok(T)` * - `Ok(null)` -> `null` * - `Err(E)` -> `Err(E)` */ export declare function transposeResultToNullable<T, E>(input: Result<Nullable<T>, E>): Nullable<Result<T, E>>; /** * Transposes a `Result` of an `Undefinable<T>` into an `Undefinable<T>` of a `Result`. * * - `Ok(T)` -> `Ok(T)` * - `Ok(undefined)` -> `undefined` * - `Err(E)` -> `Err(E)` */ export declare function transposeResultToUndefinable<T, E>(input: Result<Undefinable<T>, E>): Undefinable<Result<T, E>>;