Skip to main content

Simple library to calculate the current phase of the moon

Works with
This package works with Bun
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
64%
Published
3 months ago (1.0.1)

tinyLunarPhase

A very minimal Javascript library for working out the current lunar phase.

Examples

To get started, you can either directly import lunar.js to your HTML file or use a package manager like Deno or npm.

// Depends on what package manager you're using. This example is for regular js.
const { getMoonPhase } = require('./lunar.js');

// Create a date object, or use Date() to represent the current time.
const date = new Date('2024-02-28');

// Find the current moon phase
const moonPhase = getMoonPhase(date);

// You will recieve an object like this
{text: 'Waning Gibbous', emoji: '🌖'}

You can find a better example in the examples folder

Contributions

I accept contributions. This project is quite minimal, and I would like to keep it that way for now, but bug-fixes, documentation and smaller new features are great.

License

BSD 3-Clause - Check LICENSE for more details.

Add Package

deno add @matthew/lunar

Import symbol

import * as mod from "@matthew/lunar";

Add Package

npx jsr add @matthew/lunar

Import symbol

import * as mod from "@matthew/lunar";

Add Package

yarn dlx jsr add @matthew/lunar

Import symbol

import * as mod from "@matthew/lunar";

Add Package

pnpm dlx jsr add @matthew/lunar

Import symbol

import * as mod from "@matthew/lunar";

Add Package

bunx jsr add @matthew/lunar

Import symbol

import * as mod from "@matthew/lunar";