UNPKG

human-logic

Version:
61 lines 2.89 kB
"use strict"; /** * Polymorphic Functions * @module */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Logic = exports.FUZZY_FALSE = exports.FUZZY_TRUE = exports.TRUE = exports.MAYBE = exports.NEVER = exports.FALSE = exports.UNDEF = exports.Categories = exports.normalize = exports.or = exports.and = exports.not = void 0; /** @hidden */ var Category_1 = require("./Category"); Object.defineProperty(exports, "Categories", { enumerable: true, get: function () { return Category_1.Categories; } }); Object.defineProperty(exports, "UNDEF", { enumerable: true, get: function () { return Category_1.UNDEF; } }); Object.defineProperty(exports, "FALSE", { enumerable: true, get: function () { return Category_1.FALSE; } }); Object.defineProperty(exports, "NEVER", { enumerable: true, get: function () { return Category_1.NEVER; } }); Object.defineProperty(exports, "MAYBE", { enumerable: true, get: function () { return Category_1.MAYBE; } }); Object.defineProperty(exports, "TRUE", { enumerable: true, get: function () { return Category_1.TRUE; } }); /** @hidden */ var Fuzzy_1 = require("./Fuzzy"); Object.defineProperty(exports, "FUZZY_TRUE", { enumerable: true, get: function () { return Fuzzy_1.FUZZY_TRUE; } }); Object.defineProperty(exports, "FUZZY_FALSE", { enumerable: true, get: function () { return Fuzzy_1.FUZZY_FALSE; } }); /** @hidden */ var Logic_1 = require("./Logic"); Object.defineProperty(exports, "Logic", { enumerable: true, get: function () { return Logic_1.Logic; } }); function not(value) { if (typeof value === 'string') return (0, Category_1.not)(value); if (typeof value === 'number') return (0, Fuzzy_1.not)(value); if (typeof value === 'object') return (0, Logic_1.not)(value); throw new TypeError('Invalid argument type'); } exports.not = not; function and(a, b) { if (typeof a === 'string' && typeof b === 'string') return (0, Category_1.and)(a, b); if (typeof a === 'number' && typeof b === 'number') return (0, Fuzzy_1.and)(a, b); if (typeof a === 'object' && typeof b === 'object') return (0, Logic_1.and)(a, b); throw new TypeError('Invalid argument type'); } exports.and = and; function or(a, b) { if (typeof a === 'string' && typeof b === 'string') return (0, Category_1.or)(a, b); if (typeof a === 'number' && typeof b === 'number') return (0, Fuzzy_1.or)(a, b); if (typeof a === 'object' && typeof b === 'object') return (0, Logic_1.or)(a, b); throw new TypeError('Invalid argument type'); } exports.or = or; function normalize(value) { if (typeof value === 'number') return (0, Fuzzy_1.normalize)(value); if (typeof value === 'object') return (0, Logic_1.normalize)(value); throw new TypeError('Invalid argument type'); } exports.normalize = normalize; //# sourceMappingURL=index.js.map