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

bazi-calculator-by-alvamind

v1.0.2

Published

A comprehensive Bazi calculator for Node.js

Downloads

585

Readme

Bazi Calculator by Alvamind 八字计算器

npm version License: MIT TypeScript Downloads

A modern, accurate, and comprehensive Bazi (八字 / Four Pillars of Destiny) calculator and analyzer for Node.js environments.

InstallationQuick StartDocumentationContributing

📢 Disclaimer

This package is provided for educational and research purposes only. The calculations and interpretations should not be used as the sole basis for making important life decisions. Chinese Metaphysics and Bazi analysis require professional expertise and years of study.

✨ Features

Core Calculations

  • Four Pillars (四柱)
    • Year Pillar (年柱)
    • Month Pillar (月柱)
    • Day Pillar (日柱)
    • Hour Pillar (時柱)
  • Solar/Lunar Calendar Conversions
  • Precise Time Calculations

Analysis Components

  • Five Elements (五行) Analysis
    • Element Distribution
    • Element Relationships
    • Element Strength Calculations
  • Day Master (日主) Analysis
    • Yin/Yang Nature
    • Element Properties
    • Stem Relationships
  • Eight Mansions (八宅) Feng Shui
    • Life Gua Calculation
    • Direction Analysis
    • Lucky/Unlucky Sectors
  • Destiny Indicators
    • Nobleman (貴人)
    • Intelligence Star (文昌)
    • Sky Horse (天馬)
    • Peach Blossom (桃花)

Technical Features

  • 🔒 Type-safe with TypeScript
  • 📦 ES Module Support
  • 🏗️ SOLID Architecture
  • 🔄 JSON-based Date Mapping
  • 📝 Comprehensive Type Definitions
  • ⚡ Optimized Performance

🚀 Installation

# Using npm
npm install bazi-calculator-by-alvamind

# Using yarn
yarn add bazi-calculator-by-alvamind

# Using pnpm
pnpm add bazi-calculator-by-alvamind

🎯 Quick Start

import { BaziCalculator } from 'bazi-calculator-by-alvamind';

// Initialize calculator
const calculator = new BaziCalculator(
  1990,    // Year
  5,       // Month
  10,      // Day
  12,      // Hour (24-hour format)
  'male'   // Gender
);

// Get complete analysis
const analysis = calculator.getCompleteAnalysis();

// Display Chinese characters
console.log(calculator.toString()); // 庚午年辛巳月乙酉日壬午時

📖 Detailed Documentation

Basic Usage

Getting Basic Analysis

const basicAnalysis = calculator.calculateBasicAnalysis();

Calculating Pillars Only

const pillars = calculator.calculatePillars();

Example Output

{
  "mainPillars": {
    "year": {
      "chinese": "庚午",
      "element": "METAL",
      "animal": "Horse",
      "branch": { "element": "FIRE" }
    },
    "month": {
      "chinese": "辛巳",
      "element": "METAL",
      "animal": "Snake",
      "branch": { "element": "FIRE" }
    },
    "day": {
      "chinese": "乙酉",
      "element": "WOOD",
      "animal": "Rooster",
      "branch": { "element": "METAL" }
    },
    "time": {
      "chinese": "壬午",
      "element": "WATER",
      "animal": "Horse",
      "branch": { "element": "FIRE" }
    }
  },
  "basicAnalysis": {
    "lifeGua": 1,
    "dayMaster": {
      "stem": "乙",
      "nature": "Yin",
      "element": "WOOD"
    },
    "nobleman": ["子", "申"],
    "intelligence": "巳",
    "skyHorse": "卯",
    "peachBlossom": "酉",
    "fiveFactors": {
      "WOOD": 13,
      "FIRE": 38,
      "EARTH": 0,
      "METAL": 38,
      "WATER": 12
    },
    "eightMansions": {
      "group": "East",
      "lucky": {
        "wealth": "SE",
        "health": "E",
        "romance": "S",
        "career": "N"
      },
      "unlucky": {
        "obstacles": "NW",
        "quarrels": "W",
        "setbacks": "SW",
        "totalLoss": "NE"
      }
    }
  }
}

API Reference

BaziCalculator Class

class BaziCalculator {
  constructor(
    year: number,     // Gregorian year
    month: number,    // Month (1-12)
    day: number,      // Day (1-31)
    hour: number,     // Hour (0-23)
    gender?: GenderType // 'male' | 'female'
  )

  // Main methods
  calculatePillars(): Pillars
  calculateBasicAnalysis(): BasicAnalysis
  getCompleteAnalysis(): CompleteAnalysis
  toString(): string
}

🤝 Contributing

We welcome contributions! See our Contributing Guidelines for details.

Development Setup

# Clone repository
git clone https://github.com/yourusername/bazi-calculator-by-alvamind.git

# Install dependencies
npm install

# Run tests
npm test

# Build
npm run build

📝 Important Notes

Calculation Methods

  • Solar calendar based calculations
  • Traditional Chinese time system (12 two-hour periods)
  • Standard Stem-Branch (干支) system
  • Eight Mansions Feng Shui principles

Limitations

  • Time zone considerations
  • Lunar calendar approximations
  • Regional variations in interpretations

🙏 Acknowledgements

  • Traditional Chinese Metaphysics texts and masters
  • Modern Bazi research and practitioners
  • Open source community contributors
  • Chinese calendar conversion references

📄 License

MIT License - see the LICENSE file for details.

💬 Support

🌟 References

  1. Chinese Metaphysics Classics
  2. Modern Bazi Analysis Methods
  3. Traditional Calendar Systems
  4. Stem-Branch Theory

Made with ❤️ by Alvamind

For professional consultations, please consult a qualified Bazi practitioner.