UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

22 lines (21 loc) 651 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getValueOr = void 0; const main_1 = require("./main"); function getValueOr(alt, candidate) { if (arguments.length === 1) { return ((_candidate) => getValueOr(alt, _candidate)); } if ((0, main_1.isFunction)(candidate === null || candidate === void 0 ? void 0 : candidate.getValue)) { try { return getValueOr(alt, candidate.getValueOr(alt)); } catch (_a) { return alt; } } else { return (0, main_1.isNil)(candidate) ? alt : candidate; } } exports.getValueOr = getValueOr;