ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [ • 664 B
JavaScript
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