pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
15 lines (14 loc) • 454 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cond = void 0;
const main_1 = require("./main");
function cond(conditions) {
return (value) => {
const val = (0, main_1.getValue)(value);
const fn = conditions.reduce((alreadyFound, [test, mappable]) => {
return alreadyFound || (test(val) ? mappable : null);
}, null);
return fn && fn(val);
};
}
exports.cond = cond;