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>`.
13 lines (12 loc) • 424 B
TypeScript
import type { Nullable } from '../nullable/nullable.js';
import type { Result } from './result.js';
/**
* Unwrap `T` if _input_ is `Ok(T)`.
* Otherwise, return `null`.
*/
export declare function toNullableFromOk<T>(input: Result<T, unknown>): Nullable<T>;
/**
* Unwrap `E` if _input_ is `Err(E)`.
* Otherwise, return `null`.
*/
export declare function toNullableFromErr<E>(input: Result<unknown, E>): Nullable<E>;