UNPKG

ts-data-forge

Version:

[![npm version](https://img.shields.io/npm/v/ts-data-forge.svg)](https://www.npmjs.com/package/ts-data-forge) [![npm downloads](https://img.shields.io/npm/dm/ts-data-forge.svg)](https://www.npmjs.com/package/ts-data-forge) [![License](https://img.shields.

26 lines 945 B
import { type UnwrapErr, type UnwrapOk, type UnwrapWarn } from './types.mjs'; /** * Maps the Err variant while leaving Ok/Warn untouched. * * @example * * ```ts * const errValue = TernaryResult.err('boom'); * * const mappedErr = TernaryResult.mapErr(errValue, (error) => * error.toUpperCase(), * ); * * const warnPassthrough = TernaryResult.mapErr( * TernaryResult.warn(2, 'slow'), * (error: string) => `${error}!`, * ); * * assert.deepStrictEqual(mappedErr, TernaryResult.err('BOOM')); * * assert.deepStrictEqual(warnPassthrough, TernaryResult.warn(2, 'slow')); * ``` */ export declare function mapErr<R extends UnknownTernaryResult, E2>(result: R, mapFn: (error: UnwrapErr<R>) => E2): TernaryResult<UnwrapOk<R>, E2, UnwrapWarn<R>>; export declare function mapErr<E, E2>(mapFn: (error: E) => E2): <S, W>(result: TernaryResult<S, E, W>) => TernaryResult<S, E2, W>; //# sourceMappingURL=ternary-result-map-err.d.mts.map