UNPKG

fortel-ziweidoushu

Version:
53 lines 1.62 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Ground = void 0; const utils_1 = require("./../utils"); const util_1 = __importDefault(require("util")); const GROUND_WORDS = Object.freeze(['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥']); class Ground { index; displayName; constructor(index, displayName) { this.index = index; this.displayName = displayName; } shift(i) { return Ground.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 Ground.GROUNDS[(0, utils_1.mod)(i, 12)]; } static getByName(name) { const index = GROUND_WORDS.indexOf(name); if (index !== -1) { return Ground.get(index); } else { throw new Error('Not found'); } } static GROUNDS = Object.freeze(GROUND_WORDS.map((word, i) => { return Object.freeze(new Ground(i, word)); })); static values() { return Ground.GROUNDS; } equals(ground) { return this === ground || this.index === ground.index; } } exports.Ground = Ground; //# sourceMappingURL=ground.js.map