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

@nrweb/astro-calc

v1.0.0

Published

Comprehensive astrological calculations using Swiss Ephemeris and astronomy-engine for positions, aspects, houses, lots, and scoring metrics

Downloads

101

Readme

Astro Calculator

A comprehensive TypeScript library for astrological calculations using Swiss Ephemeris and astronomy-engine. Calculate planetary positions, aspects, houses, lots, and scoring metrics for celestial bodies with high precision.

Features

  • Planetary Positions: Calculate precise positions for all planets, Moon, and lunar nodes
  • Zodiac Signs & Dignities: Determine zodiac signs, dignities, decans, and bounds
  • Houses: Generate house systems with planet placements
  • Aspects: Calculate major aspects between planets with orbs and grades
  • Lots: Compute various Arabic parts and lots
  • Retrograde Tracking: Track retrograde periods and planetary motion
  • Scoring Systems: Romance, career, wealth, magic, friendship, and health scores
  • Planetary Hours: Calculate planetary hour rulers
  • Moon Phases: Determine lunar phases and illumination

Installation

npm install astro-calculator

Quick Start

import { getAstrologicalPositions } from "astro-calculator";

// Get astrological data for current time and default location
const chart = getAstrologicalPositions();

// Get data for specific date and location
const specificChart = getAstrologicalPositions(
  new Date("2024-03-15"),
  40.7128, // latitude
  -74.006 // longitude
);

console.log(chart.positions); // Planetary positions
console.log(chart.houses); // House system
console.log(chart.romanceScore); // Romance compatibility score

API Reference

Main Functions

getAstrologicalPositions(date?, latitude?, longitude?)

Returns a complete astrological chart with positions, houses, aspects, and scores.

Parameters:

  • date (Date, optional): Target date (defaults to current date)
  • latitude (number, optional): Latitude in degrees (defaults to Belfast)
  • longitude (number, optional): Longitude in degrees (defaults to Belfast)

Returns: Chart object containing:

  • positions: Array of planetary positions
  • houses: Array of house data
  • lots: Array of calculated lots
  • aspects: Array of planetary aspects
  • romanceScore, careerScore, wealthScore, etc.: Scoring metrics
  • planetaryHours: Planetary hour rulers
  • moonPhase: Current lunar phase information

Scoring Functions

import {
  calculateRomanceScore,
  calculateCareerScore,
  calculateWealthScore,
  calculateMagicScore,
  calculateFriendshipScore,
  calculateHealthScore,
} from "astro-calculator";

const chart = getAstrologicalPositions();
const romanceScore = calculateRomanceScore(
  chart.positions,
  chart.houses,
  chart.isDayChart
);

Usage Examples

Basic Chart Calculation

import { getAstrologicalPositions } from "astro-calculator";

const chart = getAstrologicalPositions();

// Access planetary positions
chart.positions.forEach((planet) => {
  console.log(`${planet.name}: ${planet.degrees}° ${planet.sign}`);
  console.log(`Dignity: ${planet.dignity}`);
  console.log(`Motion: ${planet.planetaryMotion}`);
});

// Access houses
chart.houses.forEach((house) => {
  console.log(
    `House ${house.number}: ${house.startDegrees}° ${house.startSign}`
  );
});

Aspect Analysis

const chart = getAstrologicalPositions();

// Find all aspects involving the Sun
const sunAspects = chart.positions.find((p) => p.name === "Sun")?.aspects || [];

sunAspects.forEach((aspect) => {
  console.log(`Sun ${aspect.type} ${aspect.planets.right}`);
  console.log(`Deviation: ${aspect.deviation}°`);
});

Historical Chart

// Calculate chart for a historical date
const historicalChart = getAstrologicalPositions(
  new Date("1969-07-20T20:17:00Z"), // Moon landing
  28.5383, // Kennedy Space Center latitude
  -80.6511 // Kennedy Space Center longitude
);

console.log("Moon landing chart:", historicalChart);

This will run the TypeScript code directly without building.

Output

The script outputs a comprehensive JSON object containing:

  • Date and Location: The date/time and coordinates used for calculations
  • Planets: Positions, motion states, dignities, and aspects for all traditional planets
  • Houses: 12 houses with planetary placements and aspects
  • Lots: Traditional lots (Fortune, Spirit, Marriage, Children, Career, Health, Wealth, Love) with positions and aspects
  • Challenges: Astrological challenges (Algol transit, aneretic degrees, Via Combusta, Void Course)
  • Moon Phase: Current lunar phase and illumination
  • Scoring Metrics: Five normalized scores (0-1) for different life areas

Scoring Metrics

The application calculates five normalized scores (0-1) for different life areas. Each score starts at 0.5 and is adjusted based on positive and negative astrological factors.

Romance Score

Positive Factors (+0.1 to +0.3 each):

  • Venus in dignity (exaltation, rulership, triplicity, term, face)
  • Venus in angular houses (1st, 4th, 7th, 10th)
  • Jupiter in dignity or angular houses
  • Moon in dignity or angular houses
  • Venus-Jupiter aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Venus-Moon aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Venus in 5th or 7th house (+0.2 each)
  • Jupiter in 5th or 7th house (+0.2 each)
  • Moon in 5th or 7th house (+0.2 each)
  • Venus not combust or retrograde (+0.1 each)
  • Jupiter not combust or retrograde (+0.1 each)
  • Moon not combust (+0.1)
  • Waxing moon phase (+0.1)
  • Lot of Love in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Venus in detriment or fall
  • Venus in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 5th or 7th house
  • Mars in 5th or 7th house
  • Venus-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Venus-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Venus combust or retrograde
  • Waning moon phase
  • Lot of Love in detriment or fall

Career Score

Positive Factors (+0.1 to +0.3 each):

  • Sun in dignity (exaltation, rulership, triplicity, term, face)
  • Sun in angular houses (1st, 4th, 7th, 10th)
  • Mercury in dignity or angular houses
  • Jupiter in dignity or angular houses
  • Sun-Jupiter aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Sun-Mercury aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Sun in 6th or 10th house (+0.2 each)
  • Mercury in 6th or 10th house (+0.2 each)
  • Jupiter in 6th or 10th house (+0.2 each)
  • Sun not combust (+0.1)
  • Mercury not combust or retrograde (+0.1 each)
  • Jupiter not combust or retrograde (+0.1 each)
  • Waxing moon phase (+0.1)
  • Lot of Career in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Sun in detriment or fall
  • Sun in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 6th or 10th house
  • Mars in 6th or 10th house
  • Sun-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Sun-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Sun combust
  • Mercury combust or retrograde
  • Waning moon phase
  • Lot of Career in detriment or fall

Wealth Score

Positive Factors (+0.1 to +0.3 each):

  • Jupiter in dignity (exaltation, rulership, triplicity, term, face)
  • Jupiter in angular houses (1st, 4th, 7th, 10th)
  • Venus in dignity or angular houses
  • Moon in dignity or angular houses
  • Jupiter-Venus aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Jupiter-Moon aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Jupiter in 2nd or 8th house (+0.2 each)
  • Venus in 2nd or 8th house (+0.2 each)
  • Moon in 2nd or 8th house (+0.2 each)
  • Jupiter not combust or retrograde (+0.1 each)
  • Venus not combust or retrograde (+0.1 each)
  • Moon not combust (+0.1)
  • Waxing moon phase (+0.1)
  • Lot of Wealth in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Jupiter in detriment or fall
  • Jupiter in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 2nd or 8th house
  • Mars in 2nd or 8th house
  • Jupiter-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Jupiter-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Jupiter combust or retrograde
  • Venus combust or retrograde
  • Waning moon phase
  • Lot of Wealth in detriment or fall

Magic Score

Positive Factors (+0.1 to +0.3 each):

  • Moon in dignity (exaltation, rulership, triplicity, term, face)
  • Moon in angular houses (1st, 4th, 7th, 10th)
  • Neptune in dignity or angular houses
  • Pluto in dignity or angular houses
  • Moon-Neptune aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Moon-Pluto aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Moon in 8th or 12th house (+0.2 each)
  • Neptune in 8th or 12th house (+0.2 each)
  • Pluto in 8th or 12th house (+0.2 each)
  • Moon not combust (+0.1)
  • Neptune not combust or retrograde (+0.1 each)
  • Pluto not combust or retrograde (+0.1 each)
  • New or full moon phase (+0.2)
  • Lot of Spirit in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Moon in detriment or fall
  • Moon in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 8th or 12th house
  • Mars in 8th or 12th house
  • Moon-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Moon-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Moon combust
  • Neptune combust or retrograde
  • Pluto combust or retrograde
  • Quarter moon phases
  • Lot of Spirit in detriment or fall

Friendship Score

Positive Factors (+0.1 to +0.3 each):

  • Venus in dignity (exaltation, rulership, triplicity, term, face)
  • Venus in angular houses (1st, 4th, 7th, 10th)
  • Jupiter in dignity or angular houses
  • Mercury in dignity or angular houses
  • Venus-Jupiter aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Venus-Mercury aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Venus in 3rd or 11th house (+0.2 each)
  • Jupiter in 3rd or 11th house (+0.2 each)
  • Mercury in 3rd or 11th house (+0.2 each)
  • Venus not combust or retrograde (+0.1 each)
  • Jupiter not combust or retrograde (+0.1 each)
  • Mercury not combust or retrograde (+0.1 each)
  • Waxing moon phase (+0.1)
  • Lot of Fortune in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Venus in detriment or fall
  • Venus in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 3rd or 11th house
  • Mars in 3rd or 11th house
  • Venus-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Venus-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Venus combust or retrograde
  • Waning moon phase
  • Lot of Fortune in detriment or fall

Health Score

Positive Factors (+0.1 to +0.3 each):

  • Sun in dignity (exaltation, rulership, triplicity, term, face)
  • Sun in angular houses (1st, 4th, 7th, 10th)
  • Moon in dignity or angular houses
  • Jupiter in dignity or angular houses
  • Sun-Moon aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Sun-Jupiter aspects (trine +0.3, sextile +0.2, conjunction +0.1)
  • Sun in 1st or 6th house (+0.2 each)
  • Moon in 1st or 6th house (+0.2 each)
  • Jupiter in 1st or 6th house (+0.2 each)
  • Sun not combust (+0.1)
  • Moon not combust (+0.1)
  • Jupiter not combust or retrograde (+0.1 each)
  • Waxing moon phase (+0.1)
  • Lot of Health in dignity or angular houses (+0.2 each)

Negative Factors (-0.1 to -0.3 each):

  • Sun in detriment or fall
  • Sun in cadent houses (3rd, 6th, 9th, 12th)
  • Saturn in 1st or 6th house
  • Mars in 1st or 6th house
  • Sun-Saturn aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Sun-Mars aspects (square -0.3, opposition -0.2, conjunction -0.1)
  • Sun combust
  • Moon combust
  • Waning moon phase
  • Lot of Health in detriment or fall

Score Calculation Details

  • Baseline: All scores start at 0.5
  • Normalization: Final scores are clamped between 0 and 1
  • Aspect Grading: Aspects are graded as "perfect" (0° orb), "joining" (1-3° orb), or "assembly" (3-10° orb)
  • House Classification: Angular (1st, 4th, 7th, 10th), Succedent (2nd, 5th, 8th, 11th), Cadent (3rd, 6th, 9th, 12th)
  • Dignities: Exaltation, rulership, triplicity, term, face, detriment, fall
  • Combust: Planets within 8° of the Sun (except traditional planets only)
  • Retrograde: Planets appearing to move backward from Earth's perspective

Development

Building the Project

npm run build

Publishing to npm

  1. Make sure you're logged in to npm:
npm login
  1. Update the version in package.json:
npm version patch  # for bug fixes
npm version minor  # for new features
npm version major  # for breaking changes
  1. Build and publish:
npm publish

The prepublishOnly script will automatically run the build before publishing.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run npm run build to ensure everything compiles
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Dependencies

  • astronomy-engine: Core astronomical calculations
  • swiss-ephemeris: High-precision planetary positions
  • suncalc: Solar calculations for sunrise/sunset
  • lune: Lunar phase calculations

Requirements

  • Node.js >= 14.0.0
  • TypeScript (for development)