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

@misque/core

v0.2.1

Published

Core utilities for Misque Islamic libraries

Readme

@misque/core

Core utilities and shared types for the Misque Islamic library ecosystem.

Installation

npm install @misque/core
# or
yarn add @misque/core
# or
pnpm add @misque/core

Features

  • Zero dependencies
  • Full TypeScript support with comprehensive type definitions
  • Tree-shakeable ESM and CommonJS builds
  • Geographic coordinate utilities (distance, validation)
  • Julian Day conversions for calendar calculations
  • Angular math helpers (radians, degrees, normalization)
  • Islamic constants (Kaaba coordinates, month names, prayer names)
  • Result type for type-safe error handling

Quick Start

import {
  calculateDistance,
  toRadians,
  toDegrees,
  normalizeAngle,
  toJulianDay,
  fromJulianDay,
  KAABA_COORDINATES,
  ISLAMIC_MONTHS,
} from '@misque/core';

// Calculate distance between two locations (in kilometers)
const london = { latitude: 51.5074, longitude: -0.1278 };
const mecca = KAABA_COORDINATES;
const distance = calculateDistance(london, mecca);
console.log(`Distance to Mecca: ${distance.toFixed(0)} km`); // ~4,566 km

// Convert angles
const radians = toRadians(180); // 3.14159...
const degrees = toDegrees(Math.PI); // 180

// Normalize angle to 0-360 range
const normalized = normalizeAngle(-90); // 270
const normalized2 = normalizeAngle(450); // 90

// Julian Day conversions
const jd = toJulianDay(new Date('2024-01-01'));
const date = fromJulianDay(jd);

API Reference

Types

Coordinates

Geographic coordinates.

interface Coordinates {
  latitude: number; // -90 to 90
  longitude: number; // -180 to 180
}

Location

Extended location with optional elevation and timezone.

interface Location extends Coordinates {
  elevation?: number;
  timezone?: string;
}

DateComponents

Date components for calendar operations.

interface DateComponents {
  year: number;
  month: number;
  day: number;
}

TimeComponents

Time components.

interface TimeComponents {
  hours: number;
  minutes: number;
  seconds?: number;
}

Result<T, E>

Type-safe result wrapper for operations that can fail.

type Result<T, E = Error> =
  | { success: true; data: T }
  | { success: false; error: E };

// Usage
function divide(a: number, b: number): Result<number> {
  if (b === 0) {
    return { success: false, error: new Error('Division by zero') };
  }
  return { success: true, data: a / b };
}

const result = divide(10, 2);
if (result.success) {
  console.log(result.data); // 5
}

LanguageCode

Supported language codes.

type LanguageCode = 'ar' | 'en' | 'fr' | 'id' | 'ms' | 'tr' | 'ur';

TextDirection

Text rendering direction.

type TextDirection = 'ltr' | 'rtl';

Utility Functions

toRadians(degrees: number): number

Convert degrees to radians.

toRadians(180); // 3.141592653589793
toRadians(90); // 1.5707963267948966

toDegrees(radians: number): number

Convert radians to degrees.

toDegrees(Math.PI); // 180
toDegrees(Math.PI / 2); // 90

normalizeAngle(angle: number): number

Normalize an angle to the 0-360 degree range.

normalizeAngle(450); // 90
normalizeAngle(-90); // 270
normalizeAngle(360); // 0

calculateDistance(from: Coordinates, to: Coordinates): number

Calculate the distance between two coordinates using the Haversine formula. Returns distance in kilometers.

const london = { latitude: 51.5074, longitude: -0.1278 };
const paris = { latitude: 48.8566, longitude: 2.3522 };
const distance = calculateDistance(london, paris);
console.log(`${distance.toFixed(1)} km`); // 343.5 km

validateCoordinates(coords: Coordinates): Result<Coordinates>

Validate that coordinates are within valid ranges.

const valid = validateCoordinates({ latitude: 51.5, longitude: -0.1 });
// { success: true, data: { latitude: 51.5, longitude: -0.1 } }

const invalid = validateCoordinates({ latitude: 100, longitude: 0 });
// { success: false, error: Error('Latitude must be between -90 and 90 degrees') }

formatTime(hours: number, minutes: number): string

Format time as HH:MM string.

formatTime(14, 30); // "14:30"
formatTime(9, 5); // "09:05"

toJulianDay(date: Date): number

Convert a JavaScript Date to Julian Day Number.

toJulianDay(new Date('2024-01-01')); // 2460310

fromJulianDay(jd: number): Date

Convert a Julian Day Number to JavaScript Date.

fromJulianDay(2460310); // Date for 2024-01-01

Constants

KAABA_COORDINATES

The geographic coordinates of the Kaaba in Mecca, Saudi Arabia.

const KAABA_COORDINATES: Coordinates = {
  latitude: 21.4225,
  longitude: 39.8262,
};

ISLAMIC_MONTHS

Names of the 12 Islamic (Hijri) months in English.

const ISLAMIC_MONTHS = [
  'Muharram',
  'Safar',
  'Rabi al-Awwal',
  'Rabi al-Thani',
  'Jumada al-Awwal',
  'Jumada al-Thani',
  'Rajab',
  'Shaban',
  'Ramadan',
  'Shawwal',
  'Dhul Qadah',
  'Dhul Hijjah',
] as const;

ISLAMIC_MONTHS_AR

Names of the 12 Islamic months in Arabic.

const ISLAMIC_MONTHS_AR = [
  'محرم',
  'صفر',
  'ربيع الأول',
  'ربيع الثاني',
  'جمادى الأولى',
  'جمادى الآخرة',
  'رجب',
  'شعبان',
  'رمضان',
  'شوال',
  'ذو القعدة',
  'ذو الحجة',
] as const;

PRAYER_NAMES

Names of the five daily prayers plus sunrise.

const PRAYER_NAMES = [
  'Fajr',
  'Sunrise',
  'Dhuhr',
  'Asr',
  'Maghrib',
  'Isha',
] as const;

PRAYER_NAMES_AR

Prayer names in Arabic.

const PRAYER_NAMES_AR = [
  'الفجر',
  'الشروق',
  'الظهر',
  'العصر',
  'المغرب',
  'العشاء',
] as const;

DAYS_OF_WEEK_AR

Days of the week in Arabic (starting with Sunday).

const DAYS_OF_WEEK_AR = [
  'الأحد',
  'الإثنين',
  'الثلاثاء',
  'الأربعاء',
  'الخميس',
  'الجمعة',
  'السبت',
] as const;

Type Aliases

IslamicMonth

Type for Islamic month names.

type IslamicMonth = (typeof ISLAMIC_MONTHS)[number];
// 'Muharram' | 'Safar' | 'Rabi al-Awwal' | ...

PrayerName

Type for prayer names.

type PrayerName = (typeof PRAYER_NAMES)[number];
// 'Fajr' | 'Sunrise' | 'Dhuhr' | 'Asr' | 'Maghrib' | 'Isha'

TypeScript Support

This package is written in TypeScript and includes complete type definitions. All exports are fully typed.

import type {
  Coordinates,
  Location,
  DateComponents,
  TimeComponents,
  Result,
  AsyncResult,
  LanguageCode,
  TextDirection,
  IslamicMonth,
  PrayerName,
} from '@misque/core';

Related Packages

License

MIT