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

saros-eclipse

v0.1.0

Published

Solar and lunar eclipse lookup from NASA's full Saros catalog (Saros 1–180)

Readme

saros-eclipse

Solar and lunar eclipse lookup from NASA's full Saros catalog.

Covers all 180 solar and 180 lunar Saros series — 13 206 solar and 12 223 lunar eclipses spanning several millennia (~2872 BCE – 4017 CE). Data is read from pre-built binary files bundled with the package; no network access or native compilation needed.

Installation

npm install saros-eclipse

Requires Node.js ≥ 18.

Quick start

import {
  findNextSolarEclipse,
  findSolarSarosWindow,
  findClosestLunarEclipse,
  SolarEclipseType,
  solarEclipseTypeLabel,
} from 'saros-eclipse';

const result = findNextSolarEclipse(new Date());
if (result.eclipse) {
  const e = result.eclipse;
  console.log(`Next solar: ${e.date.toISOString()}`);
  console.log(`  type=${solarEclipseTypeLabel(e.type)}  saros=${e.sarosNumber}[${e.sarosPos}]`);
  console.log(`  lat=${e.latitude.toFixed(1)}°  lon=${e.longitude.toFixed(1)}°`);
  if (e.centralDuration !== null)
    console.log(`  central duration=${e.centralDuration}s`);
  if (result.sarosNext)
    console.log(`  next in series: ${result.sarosNext.date.toISOString().slice(0, 10)}`);
}

// Saros 145 window (the series that produced the Aug 2017 eclipse)
const window = findSolarSarosWindow(new Date(), 145);
if (window.past)   console.log(`Saros 145 was last: ${window.past.date.toISOString().slice(0,10)}`);
if (window.future) console.log(`Saros 145 next:     ${window.future.date.toISOString().slice(0,10)}`);

// Nearest lunar eclipse
const lunar = findClosestLunarEclipse(new Date());
if (lunar.eclipse) {
  const e = lunar.eclipse;
  console.log(`Closest lunar: ${e.date.toISOString().slice(0,10)}  type=${e.type}  saros=${e.sarosNumber}`);
  if (e.totalDuration !== null)
    console.log(`  totality=${e.totalDuration}s (${Math.round(e.totalDuration/60)} min)`);
}

API

All functions accept a Timestamp — either a Date or a number (unix seconds since epoch, may be fractional).

Solar

findNextSolarEclipse(ts: Timestamp)                    => EclipseResult<SolarEclipse>
findPastSolarEclipse(ts: Timestamp)                    => EclipseResult<SolarEclipse>
findClosestSolarEclipse(ts: Timestamp)                 => EclipseResult<SolarEclipse>
findSolarSarosWindow(ts: Timestamp, sarosNumber: number) => SarosWindow<SolarEclipse>

Lunar

findNextLunarEclipse(ts: Timestamp)                    => EclipseResult<LunarEclipse>
findPastLunarEclipse(ts: Timestamp)                    => EclipseResult<LunarEclipse>
findClosestLunarEclipse(ts: Timestamp)                 => EclipseResult<LunarEclipse>
findLunarSarosWindow(ts: Timestamp, sarosNumber: number) => SarosWindow<LunarEclipse>

Return types

EclipseResult<T>

| Field | Type | Description | |---|---|---| | eclipse | T \| null | Matched eclipse; null if timestamp is outside dataset | | sarosPrev | T \| null | Previous eclipse in the same Saros series | | sarosNext | T \| null | Next eclipse in the same Saros series |

SarosWindow<T>

| Field | Type | Description | |---|---|---| | sarosNumber | number | The queried Saros series | | past | T \| null | Most recent eclipse in the series before ts | | future | T \| null | Next eclipse in the series at or after ts |

SolarEclipse

| Field | Type | Description | |---|---|---| | unixTime | number | Unix timestamp in seconds (may be negative) | | date | Date | Greatest-eclipse moment (always valid across this dataset) | | globalIndex | number | Flat index in the dataset | | sarosNumber | number | Saros series (1–180) | | sarosPos | number | 0-based position within the series | | type | SolarEclipseType | Eclipse type enum | | latitude | number | Geographic latitude of greatest eclipse (°N) | | longitude | number | Geographic longitude of greatest eclipse (°E) | | centralDuration | number \| null | Central-path duration in seconds; null if n/a | | sunAltitude | number | Sun altitude above horizon at greatest eclipse (°) |

LunarEclipse

| Field | Type | Description | |---|---|---| | unixTime | number | Unix timestamp in seconds (may be negative) | | date | Date | Greatest-eclipse moment | | globalIndex | number | Flat index in the dataset | | sarosNumber | number | Saros series (1–180) | | sarosPos | number | 0-based position within the series | | type | LunarEclipseType | Eclipse type enum | | penumbralDuration | number \| null | Penumbral phase duration in seconds | | partialDuration | number \| null | Partial phase duration in seconds | | totalDuration | number \| null | Total phase duration in seconds |

Eclipse types

Use solarEclipseTypeLabel(type) / lunarEclipseTypeLabel(type) to get the canonical NASA code string (e.g. "A+", "T-").

SolarEclipseType: A, Aplus (A+), Aminus (A-), Am, An, As, H, H2, H3, Hm, P, Pb, Pe, T, Tplus (T+), Tminus (T-), Tm, Tn, Ts

LunarEclipseType: N, Nb, Ne, Nx, P, Pb, Pe, T, Tplus (T+), Tminus (T-), Tm, Tn, Ts

Data source

Fred Espenak, NASA/GSFC (retired) — Solar Saros Series / Lunar Saros Series

License

MIT