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

taixuan-lib

v1.1.0

Published

TypeScript library for TaiXuan (太玄) divination system

Downloads

20

Readme

TaiXuan-Lib 太玄经占卜库

一个基于 TypeScript 的太玄经(扬雄)占卜库,提供多种起卦方法和完整的 81 首卦象数据。

安装

npm install taixuan-lib
# 或
pnpm add taixuan-lib

特性

  • 5 种起卦方法(随机、蓍草、骰子、硬币、报数)
  • 完整 81 首卦象数据(含赞辞、爻辞)
  • TypeScript 类型支持
  • 同时支持 ESM 和 CommonJS

快速开始

import { generate, lookupByIndex } from 'taixuan-lib';

// 随机起卦
const result = generate();
console.log(result.gua.name);  // 卦名
console.log(result.gua.zan);   // 赞辞
console.log(result.gua.yao);   // 爻辞

起卦方法

| 方法 | 函数 | 说明 | |------|------|------| | 随机 | generate() | 纯随机生成 | | 蓍草 | generateByShi() | 模拟传统蓍草分堆 | | 骰子 | generateByDice() | 1-2→一, 3-4→二, 5-6→三 | | 硬币 | generateByCoins() | 两正→一, 一正一反→二, 两反→三 | | 报数 | generateByNumber(n) | 根据输入数字起卦 |

API

起卦函数

import {
  generate,
  generateByShi,
  generateByDice,
  generateByCoins,
  generateByNumber
} from 'taixuan-lib';

// 随机起卦
const result = generate();

// 蓍草法
const result2 = generateByShi();

// 骰子法
const result3 = generateByDice();

// 硬币法
const result4 = generateByCoins();

// 数字法(确定性)
const result5 = generateByNumber(1234);

查询函数

import { lookupByIndex, lookupByCode } from 'taixuan-lib';

// 按索引查询 (1-81)
const gua = lookupByIndex(1);

// 按编码查询
const gua2 = lookupByCode([1, 1, 1, 1]);

实用工具

import {
  generateMultiple,
  searchByName,
  formatResult,
  getAllGua
} from 'taixuan-lib';

// 批量起卦
const results = generateMultiple(5);

// 按名称搜索
const guaList = searchByName('中');

// 格式化输出
const text = formatResult(result);
console.log(text);
// 输出:
// 【中】第 41 首
// 编码:2-2-2-2
// 时间:2026/3/17 15:57:45
//
// 赞辞内容...

// 获取所有卦象
const allGua = getAllGua();

数据结构

interface GuaInfo {
  index: number;        // 序号 1-81
  name: string;         // 卦名
  code: TaiXuanGua;     // 编码 [1-3, 1-3, 1-3, 1-3]
  zan?: string;         // 赞辞
  yao?: YaoInfo;        // 爻辞 (初一 ~ 上九)
}

许可证

MIT