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

iching-shifa

v1.2.0

Published

周易六爻筮法 TypeScript 库 - I Ching Six Lines Divination

Downloads

542

Readme

iching-shifa

周易六爻筮法 TypeScript 库 - I Ching Six Lines Divination

功能

  • 大衍筮法起卦 - 模拟传统蓍草起卦
  • 时间起卦 - 按年月日时四柱起卦
  • 手动输入起卦 - 输入6位爻值字符串(6/7/8/9)
  • 纳甲排盘 - 完整的六爻排盘(本卦/之卦/互卦、六亲、六兽、世应、伏神等)

安装

bun add iching-shifa
# 或
npm install iching-shifa

快速开始

import { dayan, manualQiGua, decodePan, getGuaName } from 'iching-shifa';

// 大衍筮法随机起卦
const yao = dayan();  // "778879"
console.log(getGuaName(yao));  // "履"

// 手动输入起卦
const yao2 = manualQiGua('787878');

// 完整排盘
const result = decodePan(yao, {
  year: 2024,
  month: 4,
  day: 15,
  hour: 14,
});

console.log(result.benGua.guaName);  // "革"
console.log(result.zhiGua.guaName);  // "既济"

API

起卦

| 方法 | 说明 | |------|------| | dayan() | 大衍筮法随机起卦 | | manualQiGua(input) | 手动输入6位爻值 | | getGuaName(yaoString) | 获取卦名 | | getZhiGua(yaoString) | 计算之卦 | | getHuGua(yaoString) | 计算互卦 |

排盘

| 方法 | 说明 | |------|------| | decodePan(yaoString, options) | 完整排盘,返回 PanResult | | decodeGua(yaoString, dayGanZhi) | 单卦解码 |

爻值

| 值 | 含义 | 动/静 | |----|------|-------| | 6 | 老阴 | 动爻(变阳) | | 7 | 少阳 | 静爻 | | 8 | 少阴 | 静爻 | | 9 | 老阳 | 动爻(变阴) |

JSON 输出结构

interface PanResult {
  queryTime: { year, month, day, hour, minute };
  ganZhiYear: { tian, di, gz };   // 年柱
  ganZhiMonth: { tian, di, gz };  // 月柱
  ganZhiDay: { tian, di, gz };    // 日柱
  ganZhiHour: { tian, di, gz };   // 时柱
  lunarDate: { year, month, day, isLeap };
  dayKong: string;      // 日空
  hourKong: string;     // 时空
  monthJian: string;    // 月建
  benGua: GuaPan;       // 本卦
  zhiGua: GuaPan;       // 之卦
  huGua: GuaPan;        // 互卦
  yaoString: string;    // 原始爻值
  dongYaoCount: number; // 动爻数
  explanation: string;  // 断卦说明
}

interface GuaPan {
  guaName: string;      // 卦名
  palace: string;       // 所属宫
  palaceWuXing: string; // 宫五行
  palaceLevel: string;  // 宫位(本宫/一世/.../游魂/归魂)
  yaoList: YaoData[];   // 六爻详情
  guaCi: string;        // 卦辞
  yaoCi: string[];      // 爻辞
  tuanCi: string;       // 彖辞
  shenYao?: number;     // 身爻
  fuShen?: FuShenData[];// 伏神
}

interface YaoData {
  position: number;     // 爻位 1-6
  yaoValue: number;     // 爻值 6/7/8/9
  isMoving: boolean;    // 是否动爻
  tianGan: string;      // 天干
  diZhi: string;        // 地支
  naJia: string;        // 纳甲
  wuXing: string;       // 五行
  liuQin: string;       // 六亲
  liuShou: string;      // 六兽
  shiYing: string;      // 世应标记
}

开发

# 安装依赖
bun install

# 构建
bun run build

# 测试
bun test

# 监听测试
bun test --watch

测试输出示例

$ bun test

 12 pass
 0 fail
 67 expect() calls
Ran 12 tests across 1 file. [33.00ms]

许可

MIT License

相关项目