lunisolar
Version:
专业农历库,支持公历阴历互转,支持各类黄历数据查询,如八字四柱、阴历、神煞宜忌、时辰吉凶、建除十二神、胎神占方、五行纳音等。支持自定义插件。
26 lines (23 loc) • 755 B
text/typescript
import zh from './locale/zh'
import { TheGods } from './class/theGods'
import { God } from './class/god'
import { setTheGodsLocales } from './utils'
const theGods: lunisolar.PluginFunc = async (options, lsClass, lsFactory) => {
lsFactory.locale(zh, true)
setTheGodsLocales(lsFactory._globalConfig.locales)
const lsProto = lsClass.prototype
Object.defineProperty(lsProto, 'theGods', {
get(): TheGods {
if (this.cache.has('theGods')) {
const cacheData = this.cache.get('theGods')
if (cacheData instanceof TheGods) return cacheData
}
const theGods = new TheGods(this)
this.cache.set('theGods', theGods)
return theGods
}
})
}
theGods.TheGods = TheGods
theGods.God = God
export default theGods