UNPKG

brn

Version:

simple functional branching logic

16 lines (15 loc) 439 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const branch = function (test, left, right) { let leftActual = left ?? identity; let rightActual = right ?? identity; return function (...args) { if (test(...args)) { return leftActual(...args); } return rightActual(...args); }; }; exports.default = branch; module.exports = branch; const identity = (x) => x;