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

baziflow-core

v0.1.0

Published

Accurate BaZi (Four Pillars of Destiny) chart engine: four pillars, true solar time, Five Elements, Ten Gods, hidden stems, NaYin and luck pillars. Typed, dependency-light, EN/CN/TW/JA labels.

Readme

baziflow-core

Accurate BaZi (八字 / Four Pillars of Destiny) chart engine for JavaScript & TypeScript.

Give it a birth date, time and place — it returns the four pillars, true solar time, the Five Elements (五行) distribution, the Ten Gods (十神), hidden stems (藏干), NaYin (纳音) and the Luck Pillars (大运). Fully typed, tree-shakeable, one runtime dependency.

Maintained by the team behind BaziFlow — a free online BaZi calculator.

Install

npm install baziflow-core

Usage

import { computeChart } from "baziflow-core";

const chart = computeChart({
  year: 1990,
  month: 6,
  day: 15,
  hour: 14,
  minute: 30,
  gender: "male",
  longitude: 116.4, // Beijing — enables true-solar-time correction
});

console.log(chart.day.gan, chart.day.zhi); // Day pillar, e.g. 丁 巳
console.log(chart.dayMaster, chart.dayMasterElement); // 丁 "fire"
console.log(chart.trueSolarTime); // "14:16"
console.log(chart.elementStrength); // { wood: 12, fire: 40, earth: 18, metal: 15, water: 15 }
console.log(chart.luckCycles[0]); // first Luck Pillar (大运)

Lunar dates

computeChart({ year: 1990, month: 5, day: 22, hour: 8, gender: "female", calendar: "lunar" });

Just the primitives

Everything the engine uses is exported for building your own tools:

import {
  calcTrueSolarTime, // true solar time from longitude
  getTenGod,         // Ten God between two stems
  getNayin,          // NaYin for a stem/branch pair
  calcElementStrength,
  GAN_ELEMENT, ZHI_HIDDEN_GAN, GAN_COMBINE,
  romanizeGan, zodiacEn,
} from "baziflow-core";

What it returns

computeChart returns a BaziChart:

| Field | Meaning | | --- | --- | | year / month / day / hour | The four Pillars (stem, branch, elements, Ten God, hidden stems, NaYin) | | dayMaster / dayMasterElement | The Day Master stem (日主) and its element | | elementStrength | Five Elements distribution, percentages summing to ~100 | | luckCycles / currentLuckCycleIndex | Luck Pillars (大运) and the active decade | | trueSolarTime | Time used for the hour pillar after longitude correction | | solarDate / lunarDate / zodiac | Gregorian date, Chinese lunar date, zodiac animal (CN + EN) |

Scope

This package computes the chart, not a reading. It deliberately ships no fortune-telling judgements — no favourable/unfavourable elements, no strength verdict, no interpretation. Those are opinionated and belong to your product. For a full interpreted reading, try the hosted BaziFlow calculator.

Labels for NaYin ship in English, Simplified Chinese, Traditional Chinese and Japanese via formatNayin(value, locale).

License

MIT © BaziFlow