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.

21 lines (18 loc) 642 B
import { unwrapErr } from './result-unwrap-err.mjs'; function unwrapErrOr(...args) { switch (args.length) { case 2: { // Direct version: first argument is result const [result, defaultValue] = args; return unwrapErrOrImpl(result, defaultValue); } case 1: { // Curried version const [defaultValue] = args; return (result) => unwrapErrOrImpl(result, defaultValue); } } } const unwrapErrOrImpl = (result, defaultValue) => unwrapErr(result) ?? defaultValue; export { unwrapErrOr }; //# sourceMappingURL=result-unwrap-err-or.mjs.map