UNPKG

lunisolar

Version:

专业农历库,支持公历阴历互转,支持各类黄历数据查询,如八字四柱、阴历、神煞宜忌、时辰吉凶、建除十二神、胎神占方、五行纳音等。支持自定义插件。

29 lines (25 loc) 964 B
import { GodBase } from './godBase' import { trans } from '../utils' import { godKeysSet } from '../constants/godDict' import { getGodLuckLevel } from '../utils/c8Gods' export class C8God extends GodBase { readonly luckLevel: number = 0 static godkeysSet = godKeysSet static instances = new Map<string, C8God>() static create(godKey: string, config?: ClassCommonConfig): C8God { const lang = config?.lang || 'zh' const instMapKey = `${godKey}:${lang}` if (C8God.instances.has(instMapKey)) return C8God.instances.get(instMapKey) as C8God const inst = new C8God(godKey, config) C8God.instances.set(instMapKey, inst) return inst } constructor(godKey: string, config?: ClassCommonConfig) { if (!godKeysSet.has(godKey)) throw new Error(`錯誤的八字神煞key:${godKey}`) super(godKey, config) this.luckLevel = getGodLuckLevel(godKey) } get name() { return trans(`gods.${this.key}`, this._config.lang) } }