UNPKG

@mobily/ts-belt

Version:

🔧 Fast, modern, and practical utility library for FP in TypeScript.

151 lines (148 loc) • 2.98 kB
var __defProp = Object.defineProperty; var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); var __export = (target, all) => { __markAsModule(target); for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // src/Bool/index.js __export(exports, { and: () => and, ifElse: () => ifElse, implies: () => implies, inverse: () => inverse, nand: () => nand, nor: () => nor, not: () => not, or: () => or, placeholder: () => placeholder, xnor: () => xnor, xor: () => xor }); // src/Bool/Bool.bs.js function placeholder(param) { } function _ifElse(value, truthyFn, falsyFn) { if (value) { return truthyFn(void 0); } else { return falsyFn(void 0); } } function ifElse() { if (arguments.length === 2) { const args = arguments; return function fn(data) { return _ifElse(data, args[0], args[1]); }; } return _ifElse(arguments[0], arguments[1], arguments[2]); } function inverse(value) { return !value; } function not(value) { return !value; } function _and_(a, b) { if (a) { return b; } else { return false; } } function and() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _and_(data, args[0]); }; } return _and_(arguments[0], arguments[1]); } function _or_(a, b) { if (a) { return true; } else { return b; } } function or() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _or_(data, args[0]); }; } return _or_(arguments[0], arguments[1]); } function _nand(a, b) { return !(a && b); } function nand() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _nand(data, args[0]); }; } return _nand(arguments[0], arguments[1]); } function _nor(a, b) { return !(a || b); } function nor() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _nor(data, args[0]); }; } return _nor(arguments[0], arguments[1]); } function _xor(a, b) { if (!a && b) { return true; } else if (a) { return !b; } else { return false; } } function xor() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _xor(data, args[0]); }; } return _xor(arguments[0], arguments[1]); } function _xnor(a, b) { return !xor(a, b); } function xnor() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _xnor(data, args[0]); }; } return _xnor(arguments[0], arguments[1]); } function _implies(a, b) { if (a) { return b; } else { return true; } } function implies() { if (arguments.length === 1) { const args = arguments; return function fn(data) { return _implies(data, args[0]); }; } return _implies(arguments[0], arguments[1]); }