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

14 lines (13 loc) 711 B
import type { FilterFn, TypePredicateFn } from '../internal/function.js'; import { type Result, type Ok } from './result.js'; /** * Returns `true` if the _result_ is `Ok<T>` and the value inside of it matches a _predicate_. */ export declare function isOkAndForResult<T, E>(result: Result<T, E>, predicate: FilterFn<T>): boolean; /** * Returns `true` if the _result_ is `Ok<T>` and the value inside of it matches a _predicate_. * Then _result_ would be `Ok<U>`. * * Please use {@link isOkAndForResult} generally if you don't have to narrow the type. */ export declare function isOkAndWithEnsureTypeForResult<T, E, U extends T>(result: Result<T, E>, predicate: TypePredicateFn<T, U>): result is Ok<U>;