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) • 728 B
TypeScript
import type { FilterFn, TypePredicateFn } from '../../internal/function.js';
import { type Result, type Err } from '../core/result.js';
/**
* Returns `true` if the _result_ is `Err<E>` and the value inside of it matches a _predicate_.
*/
export declare function isErrAndForResult<T, E>(result: Result<T, E>, predicate: FilterFn<E>): boolean;
/**
* Returns `true` if the _result_ is `Ok<T>` and the value inside of it matches a _predicate_.
* Then _result_ would be `Err<F>`.
*
* Please use {@link isErrAndForResult} generally if you don't have to narrow the type.
*/
export declare function isErrAndWithEnsureTypeForResult<T, E, F extends E>(result: Result<T, E>, predicate: TypePredicateFn<E, F>): result is Err<F>;