UNPKG

@drewsonne/maya-dates

Version:

Typescript package to manipulate dates in the Maya Calendar

34 lines 1.51 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.coefficientParser = coefficientParser; var wildcard_1 = require("../../wildcard"); var wildcardCoefficient_1 = __importDefault(require("./wildcardCoefficient")); var numberCoefficient_1 = __importDefault(require("./numberCoefficient")); var coefficientNumberCoefficient = {}; function coefficientParser(rawCoefficient) { var hash = "".concat(rawCoefficient); if (coefficientNumberCoefficient[hash] === undefined) { if ((0, wildcard_1.isWildcard)(rawCoefficient)) { coefficientNumberCoefficient[hash] = new wildcardCoefficient_1.default(); } else if (typeof rawCoefficient == 'number') { coefficientNumberCoefficient[hash] = new numberCoefficient_1.default(rawCoefficient); } else { if (rawCoefficient == '*') { coefficientNumberCoefficient[hash] = new wildcardCoefficient_1.default(); } else if (!isNaN(+rawCoefficient)) { coefficientNumberCoefficient[hash] = new numberCoefficient_1.default(+rawCoefficient); } else { throw new Error("String coefficient is neither wildcard nor numeric"); } } } return coefficientNumberCoefficient[hash]; } //# sourceMappingURL=coefficient.js.map