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>`.
41 lines (40 loc) • 1.88 kB
TypeScript
import { type Maybe } from '../../maybe/maybe.js';
import { type Nullable, type NotNull } from '../../nullable/nullable.js';
import { type Undefinable, type NotUndefined } from '../../undefinable/undefinable.js';
import { type Option as PlainOption } from '../plain_option/option.js';
import { type ClassicOption } from './classic_option.js';
/**
* Return `PlainOption`'s `Some(T)` with the inner T if _classic_ is `ClassicSome(T)`.
* Otherwise, return `PlainOption`'s `None`.
*/
export declare function compatToPlainOption<T>(classic: ClassicOption<T>): PlainOption<T>;
/**
* Return `ClassicNone` if _plain_ is `PlainOption`'s `None`.
* Otherwise, return `ClassicSome(T)` with _plain_'s inner value `T`.
*/
export declare function compatToClassicOption<T>(plain: PlainOption<T>): ClassicOption<T>;
/**
* Return the inner `T` if _input_ is `ClassicSome(T)`.
* Otherwise, return `null.
*/
export declare function compatToNullableFromClassicOption<T>(input: ClassicOption<NotNull<T>>): Nullable<T>;
/**
* Return `ClassicNone` if _input_ is `null`.
* Otherwise, return `ClassicSome(T)` with _input_ `T`.
*/
export declare function compatToClassicOptionFromNullable<T>(input: Nullable<T>): ClassicOption<T>;
/**
* Return the inner `T` if _input_ is `ClassicSome(T)`.
* Otherwise, return `null.
*/
export declare function compatToUndefinableFromClassicOption<T>(input: ClassicOption<NotUndefined<T>>): Undefinable<T>;
/**
* Return `ClassicNone` if _input_ is `undefined`.
* Otherwise, return `ClassicSome(T)` with _input_ `T`.
*/
export declare function compatToClassicOptionFromUndefinable<T>(input: Undefinable<T>): ClassicOption<T>;
/**
* Return `ClassicNone` if _input_ is `null` or `undefined`.
* Otherwise, return `ClassicSome(T)` with _input_ `T`.
*/
export declare function compatToClassicOptionFromMaybe<T>(input: Maybe<T>): ClassicOption<T>;