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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@solarita-sdk/typescript

v0.0.7

Published

A TypeScript SDK for calculating Chinese astrology (Kanshi) and zodiac signs with high-precision astronomical calculations using astronomy-engine (Node.js) and pure JavaScript fallback (mobile/web)

Downloads

185

Readme

solarita-sdk

A TypeScript SDK for calculating Chinese and Western astrology with high-precision calculations.

Installation

npm install solarita-sdk

Usage

Basic Usage

import { getKanshi, getZodiac, getSolaritaType } from 'solarita-sdk';

// Create a Date object with birth date and time
const birthday = new Date('1990-05-15T14:30:00');

// Get Kanshi (Chinese astrology) information
const kanshi = getKanshi(birthday);
console.log(kanshi);
// Output:
// {
//   yearStemType: "Steel",
//   yearStemChar: "庚",
//   yearStemCode: "6",
//   yearAnimal: "Horse",
//   yearAnimalChar: "午",
//   yearAnimalCode: "a07",
//   // ... more properties
// }

// Get Western astrology information
const zodiac = getZodiac(birthday);
console.log(zodiac);
// Output:
// {
//   sunSign: "Taurus",
//   sunCode: "b",
//   moonSign: "Gemini",
//   moonCode: "c",
//   mercurySign: "Taurus",
//   mercuryCode: "b",
//   // ... more properties
// }

// Get Solarita type (combination of zodiac and day stem)
const solaritaType = getSolaritaType(birthday);
console.log(solaritaType);
// Output: "b6" (example)

API Reference

getKanshi(birthday: Date): Kanshi

Calculates the Chinese astrology (Kanshi) information for a given birth date and time.

Parameters:

  • birthday: Date object containing birth date and time

Returns:

  • Kanshi object containing:
    • yearStemType, yearStemChar, yearStemCode: Year stem information
    • yearAnimal, yearAnimalChar, yearAnimalCode: Year animal information
    • monthStemType, monthStemChar, monthStemCode: Month stem information
    • monthAnimal, monthAnimalChar, monthAnimalCode: Month animal information
    • dayStemType, dayStemChar, dayStemCode: Day stem information
    • dayAnimal, dayAnimalChar, dayAnimalCode: Day animal information
    • hourStemType, hourStemChar, hourStemCode: Hour stem information
    • hourAnimal, hourAnimalChar, hourAnimalCode: Hour animal information
    • color: RGB color string corresponding to dayStemType

getZodiac(birthday: Date, latitude?: number, longitude?: number): ZodiacInfo

Calculates the Western astrology information for a given birth date and location.

Parameters:

  • birthday: Date object containing birth date and time
  • latitude: Latitude of birth location (default: 35.6762 - Tokyo)
  • longitude: Longitude of birth location (default: 139.6503 - Tokyo)

Returns:

  • ZodiacInfo object containing:
    • sunSign, sunCode: Sun sign information
    • moonSign, moonCode: Moon sign information
    • mercurySign, mercuryCode: Mercury sign information
    • venusSign, venusCode: Venus sign information
    • marsSign, marsCode: Mars sign information
    • jupiterSign, jupiterCode: Jupiter sign information
    • saturnSign, saturnCode: Saturn sign information
    • uranusSign, uranusCode: Uranus sign information
    • neptuneSign, neptuneCode: Neptune sign information
    • plutoSign, plutoCode: Pluto sign information
    • ascendant, ascendantCode: Ascendant (rising sign) information
    • MC, MCCode: Midheaven (MC) information
    • northNode, northNodeCode: North Node information

getSolaritaType(birthday: Date): string

Calculates the Solarita type (combination of zodiac sign and day stem).

Parameters:

  • birthday: Date object containing birth date and time

Returns:

  • String representing the Solarita type (e.g., "b6")

Types

Kanshi

type Kanshi = {
  hourStemType: string;
  hourStemChar: string;
  hourStemCode: string;
  dayStemType: string;
  dayStemChar: string;
  dayStemCode: string;
  monthStemType: string;
  monthStemChar: string;
  monthStemCode: string;
  yearStemType: string;
  yearStemChar: string;
  yearStemCode: string;
  hourAnimal: string;
  hourAnimalChar: string;
  hourAnimalCode: string;
  dayAnimal: string;
  dayAnimalChar: string;
  dayAnimalCode: string;
  monthAnimal: string;
  monthAnimalChar: string;
  monthAnimalCode: string;
  yearAnimal: string;
  yearAnimalChar: string;
  yearAnimalCode: string;
  /** RGB color corresponding to dayStemType */
  color: string;
};

ZodiacInfo

type ZodiacInfo = {
  sunSign: string;
  sunCode: string;
  moonSign: string;
  moonCode: string;
  mercurySign: string;
  mercuryCode: string;
  venusSign: string;
  venusCode: string;
  marsSign: string;
  marsCode: string;
  jupiterSign: string;
  jupiterCode: string;
  saturnSign: string;
  saturnCode: string;
  uranusSign: string;
  uranusCode: string;
  neptuneSign: string;
  neptuneCode: string;
  plutoSign: string;
  plutoCode: string;
  ascendant: string;
  ascendantCode: string;
  MC: string;
  MCCode: string;
  northNode: string;
  northNodeCode: string;
};

Features

  • High Precision: Uses astronomy-engine for accurate astronomical calculations
  • Chinese Astrology: Complete Kanshi (Four Pillars) calculations
  • Western Astrology: All major planets and points including Ascendant, MC, and North Node
  • TypeScript Support: Full type definitions included
  • Location Support: Customizable latitude/longitude for accurate house calculations
  • Performance: Optimized calculations for both Node.js and mobile/web environments

Development

Building

npm run build

Testing

npm test

Type Checking

npm run typecheck

Publishing

Important: Supabase Functions import this SDK via npm. After making changes to the SDK, you must publish a new version to npm to ensure the functions use the updated code.

# Update version in package.json
npm version patch  # or minor/major

# Build and publish
npm run build
npm publish

License

MIT