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) 687 B
import { isWarn } from './ternary-result-is-warn.mjs'; /** * Safely unwraps the Warn value. * * @example * * ```ts * const warnValue = TernaryResult.warn('ok', 'careful'); * * const okValue = TernaryResult.ok('ok'); * * assert.strictEqual(TernaryResult.unwrapWarn(warnValue), 'careful'); * * // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression * assert.strictEqual(TernaryResult.unwrapWarn(okValue), undefined); * ``` */ const unwrapWarn = (result) => // eslint-disable-next-line total-functions/no-unsafe-type-assertion isWarn(result) ? result.warning : undefined; export { unwrapWarn }; //# sourceMappingURL=ternary-result-unwrap-warn.mjs.map