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) 609 B
import type { TransformFn } from '../../internal/function.js'; import { type Result } from '../core/result.js'; export type ResultTryTransformFn<in T, out U, out E> = TransformFn<T, Result<U, E>>; /** * Returns `Err(E)` if the _input_ is `Err(E)`, * otherwise calls _transformer_ with the value and returns the result. * * XXX: * Some languages call this operation flatmap. * But we don't provide `flatMap()` as alias of this function * to sort with other APIs. */ export declare function andThenForResult<T, U, E>(input: Result<T, E>, transformer: ResultTryTransformFn<T, U, E>): Result<U, E>;