UNPKG

fortel-ziweidoushu

Version:
53 lines 1.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Sky = void 0; const utils_1 = require("./../utils"); const util_1 = __importDefault(require("util")); const SKY_WORDS = Object.freeze(['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸']); class Sky { index; displayName; constructor(index, displayName) { this.index = index; this.displayName = displayName; } shift(i) { return Sky.get(this.index + i); } toJSON() { return this.displayName; } toString() { return this.displayName; } // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars [util_1.default.inspect.custom](depth, opts) { return this.toString(); } static get(i) { return Sky.SKYS[(0, utils_1.mod)(i, Sky.SKYS.length)]; } static getByName(name) { const index = SKY_WORDS.indexOf(name); if (index !== -1) { return Sky.get(index); } else { throw new Error('Not found'); } } static SKYS = Object.freeze(SKY_WORDS.map((word, i) => { return Object.freeze(new Sky(i, word)); })); static values() { return Sky.SKYS; } equals(sky) { return this === sky || this.index === sky.index; } } exports.Sky = Sky; //# sourceMappingURL=sky.js.map