Skip to main content
Home

Simple library to calculate the current phase of the moon

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
64%
Published
a year 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.

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@matthew/lunar

Import symbol

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

Import directly with a jsr specifier

import * as lunar from "jsr:@matthew/lunar";

Add Package

pnpm i jsr:@matthew/lunar
or (using pnpm 10.8 or older)
pnpm dlx jsr add @matthew/lunar

Import symbol

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

Add Package

yarn add jsr:@matthew/lunar
or (using Yarn 4.8 or older)
yarn dlx jsr add @matthew/lunar

Import symbol

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

Add Package

vlt install jsr:@matthew/lunar

Import symbol

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

Add Package

npx jsr add @matthew/lunar

Import symbol

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

Add Package

bunx jsr add @matthew/lunar

Import symbol

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