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

21 lines (20 loc) 1.04 kB
import type { FilterFn, TypePredicateFn } from '../../internal/function.js'; import { type Maybe, type NotNullOrUndefined } from '../core/maybe.js'; /** * Returns `undefined` if the _input_ is `null` or `undefined`, * otherwise calls _predicate_ with the _input_ `T` and returns: * * * `T` if _predicate_ returns `true`. * * `nundefined` if _predicate_ returns `false`. */ export declare function filterForMaybe<T>(input: Maybe<T>, predicate: FilterFn<T>): Maybe<T>; /** * Returns `undefined` if the _input_ is `null` or `undefined`, * otherwise calls _predicate_ with the _input_ `T` and returns: * * * The input value as `U` if _predicate_ returns `true` which means that _predicate_ says the input value is U. * * `undefined` if _predicate_ returns `false`. * * Please use {@link filterForMaybe} generally if you don't have to narrow the type. */ export declare function filterWithEnsureTypeForMaybe<T, U extends T>(input: Maybe<T>, predicate: TypePredicateFn<T, NotNullOrUndefined<U>>): Maybe<U>;