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.

22 lines 677 B
import { type UnwrapErr, type UnwrapOk } from './types.mjs'; /** * Swaps the success and error values of a `Result`. * * @example * * ```ts * const okValue = Result.ok('value'); * * const errValue = Result.err('error'); * * assert.deepStrictEqual(Result.swap(okValue), Result.err('value')); * * assert.deepStrictEqual(Result.swap(errValue), Result.ok('error')); * ``` * * @template R The input `UnknownResult` type. * @param result The `Result` to swap. * @returns A new `Result` with success and error swapped. */ export declare const swap: <R extends UnknownResult>(result: R) => Result<UnwrapErr<R>, UnwrapOk<R>>; //# sourceMappingURL=result-swap.d.mts.map