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

meihua-ts-lib

v0.1.0

Published

梅花易数排盘 TypeScript 库,支持传统时间起卦、数值化起卦、本互变与体用五行关系。

Downloads

179

Readme

meihua-ts-lib

梅花易数排盘 TypeScript 库。首版聚焦排盘数据:起卦、本卦、互卦、变卦、动爻、体用与五行关系,不输出断语,也不实现纳甲、六亲、世应、六神。

安装

bun add meihua-ts-lib

也可以用 npm、pnpm、yarn 安装;包同时提供 ESM、CJS 和 TypeScript 类型声明。

时间起卦

时间起卦采用传统梅花口径:农历年支数、农历月、农历日、时支数。公历输入会通过 tyme4ts 转为农历。

import { qiGuaByTime } from "meihua-ts-lib";

const chart = qiGuaByTime({
  calendar: "lunar",
  year: 2024,
  month: 3,
  day: 17,
  hour: 16,
});

console.log(chart.mainHexagram.fullName); // 天泽履
console.log(chart.movingLine); // 4
console.log(chart.changedHexagram.fullName); // 风泽中孚
console.log(chart.mutualHexagram.fullName); // 风火家人
console.log(chart.oppositeHexagram.fullName); // 地山谦
console.log(chart.reversedHexagram.fullName); // 风天小畜
console.log(chart.time?.ganzhi.day.name); // 己未
console.log(chart.time?.dayVoidBranches.map((branch) => branch.name)); // ["子", "丑"]

公历输入:

import { qiGuaByTime } from "meihua-ts-lib";

const chart = qiGuaByTime({
  calendar: "solar",
  year: 2024,
  month: 4,
  day: 25,
  hour: 16,
});

数值化起卦

报数、字数、声音、物数、方位外应等方法在首版中统一为数值化入口。库不内置汉字笔画数据;调用方先把笔画、字数、物数或外应转换成数字。

import { qiGuaByCounts } from "meihua-ts-lib";

const chart = qiGuaByCounts({
  method: "word",
  upper: 9,
  lower: 10,
  moving: 10,
  label: "字占示例",
});

取数规则:

上卦 = upper 对 8 取余,余 0 作 8
下卦 = lower 对 8 取余,余 0 作 8
动爻 = moving 对 6 取余,余 0 作 6

不传 moving 时使用 upper + lower

直接按卦起盘

import { qiGuaByTrigrams } from "meihua-ts-lib";

const chart = qiGuaByTrigrams({
  upper: "乾",
  lower: "兑",
  movingLine: 4,
});

八卦键名直接使用中文卦名:

乾 兑 离 震 巽 坎 艮 坤

结果结构

{
  mainHexagram,
  mutualHexagram,
  changedHexagram,
  oppositeHexagram,
  reversedHexagram,
  movingLine,
  body,
  use,
  elementRelation,
  source,
  time
}

爻序始终自下而上。elementRelation 只表达体用五行关系,例如 sameuseGeneratesBodybodyGeneratesUseuseControlsBodybodyControlsUse,不输出吉凶断语。

time 只在 qiGuaByTime 中返回,包含阳历时间、农历时间、年月日时干支,以及各柱对应旬空;其中 dayVoidBranches 是排盘常用的日旬空快捷字段。

开发

bun install
bun run typecheck
bun test
bun run build
bun run test:dist