npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bashen-ts-lib

v1.0.0

Published

八神法占卜 TypeScript 库 - 用于传统占卜术数计算

Readme

bashen-ts-lib

八神法占卜 TypeScript 库 - 用于传统占卜术数计算

介绍

八神法是一种传统占卜术,起课简单,使用方便,准确度稳定。本库提供了完整的八神法占卜算法实现。

安装

npm install bashen-ts-lib
# 或
pnpm add bashen-ts-lib
# 或
yarn add bashen-ts-lib

使用方法

基础用法

import { divinate, TianGan, DiZhi } from 'bashen-ts-lib'

// 使用时干法占卜 - 甲寅时
const result = divinate({
  gan: TianGan.Jia,
  zhi: DiZhi.Yin,
})

console.log(result)
// {
//   ganZhi: { gan: '甲', zhi: '寅' },
//   gongWei: { gan: '震', zhi: '离' },
//   shenPan: { 震: '青龙', 巽: '六合', ... },
//   timestamp: Date
// }

查看宫位

import { getPaiGongWei, TianGan, DiZhi } from 'bashen-ts-lib'

const gongWei = getPaiGongWei({
  gan: TianGan.Jia,
  zhi: DiZhi.Yin,
})

console.log(gongWei)
// { gan: '震', zhi: '离' }

查看神盘

import { getPaiShenPan, TianGan, DiZhi } from 'bashen-ts-lib'

const shenPan = getPaiShenPan({
  gan: TianGan.Yi,
  zhi: DiZhi.Mao,
})

console.log(shenPan)
// { 震: '六合', 巽: '朱雀', 离: '腾蛇', ... }

API 文档

枚举类型

  • TianGan: 十天干 (甲、乙、丙、丁、戊、己、庚、辛、壬、癸)
  • DiZhi: 十二地支 (子、丑、寅、卯、辰、巳、午、未、申、酉、戌、亥)
  • Bagua: 后天八卦 (震、巽、离、艮、兑、乾、坎、坤)
  • BaShen: 八神 (青龙、六合、朱雀、腾蛇、勾陈、贵人、白虎、玄武)

核心函数

divinate(ganZhi: GanZhi): DivinationResult

执行完整的八神法占卜

  • 参数: ganZhi - 干支时辰
  • 返回: 完整的占卜结果,包括宫位和神盘

getPaiGongWei(ganZhi: GanZhi): GongWei

排干支宫 - 计算天干地支对应的八卦宫位

  • 参数: ganZhi - 干支时辰
  • 返回: 宫位信息

getPaiShenPan(ganZhi: GanZhi): ShenPan

排神盘 - 根据天干确定八神在八卦中的分布

  • 参数: ganZhi - 干支时辰
  • 返回: 神盘映射

工具函数

  • tianGanToBagua(gan: TianGan): Bagua - 天干转八卦
  • diZhiToBagua(zhi: DiZhi): Bagua - 地支转八卦
  • getStartBaShen(gan: TianGan): BaShen - 获取天干对应的起始八神

开发

# 安装依赖
pnpm install

# 开发模式(监听文件变化)
pnpm dev

# 构建
pnpm build

# 代码检查
pnpm lint

# 代码格式化
pnpm format

原理说明

排干支宫

天干从震开始顺数:

  • 甲→震, 乙→巽, 丙→离, 丁→艮, 戊→兑, 己→乾, 庚→坎, 辛→坤, 壬→震...

地支从震开始顺数:

  • 子→震, 丑→巽, 寅→离, 卯→艮, 辰→兑, 巳→乾, 午→坎, 未→坤, 申→震...

排神盘

天干起始八神:

  • 甲日起青龙, 乙日起六合, 丙朱雀, 丁腾蛇, 戊勾陈, 己贵人, 庚辛白虎, 壬癸玄武

从震宫开始,按八卦顺序(震→巽→离→艮→兑→乾→坎→坤)排列八神。

License

MIT