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>`.
10 lines (9 loc) • 476 B
TypeScript
import type { AsyncTransformFn } from '../internal/function.js';
import { type Result } from './result.js';
/**
* Maps a `Result<T, E>` to `Result<U, E>` by applying a _transformer_ function
* to an contained `Ok(T)` value, leaving an `Err(E)` value untouched.
*
* This function can be used to compose the results of two functions.
*/
export declare function mapAsyncForResult<T, U, E>(input: Result<T, E>, transformer: AsyncTransformFn<T, U>): Promise<Result<U, E>>;