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.

25 lines (22 loc) 664 B
import { isErr } from './ternary-result-is-err.mjs'; /** * Safely unwraps the Err value. * * @example * * ```ts * const errValue = TernaryResult.err('fail'); * * const okValue = TernaryResult.ok('value'); * * assert.strictEqual(TernaryResult.unwrapErr(errValue), 'fail'); * * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression * assert.strictEqual(TernaryResult.unwrapErr(okValue), undefined); * ``` */ const unwrapErr = (result) => // eslint-disable-next-line total-functions/no-unsafe-type-assertion isErr(result) ? result.value : undefined; export { unwrapErr }; //# sourceMappingURL=ternary-result-unwrap-err.mjs.map