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>`.
9 lines (8 loc) • 536 B
TypeScript
import type { TransformFn, RecoveryFromErrorFn } from '../internal/function.js';
import { type Result } from './result.js';
/**
* Maps a `Result<T, E>` to `U` by applying _transformer_ to a contained `Ok(T)` value in _input_,
* or a _recoverer_ function to a contained `Err(E)` value in _input_.
* This function can be used to unpack a successful result while handling an error.
*/
export declare function mapOrElseForResult<T, E, U>(input: Result<T, E>, recoverer: RecoveryFromErrorFn<E, U>, transformer: TransformFn<T, U>): U;