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

salah-calculator

v1.0.0

Published

Pure TypeScript Islamic prayer times calculation library. Part of Adwatak (https://adwatak.cloud).

Readme

islamic-prayer-times

Pure TypeScript library for calculating Islamic prayer times. Part of Adwatak.

🌐 Live Demo

Try the interactive version at adwatak.cloud/tools/prayer-times

Installation

npm install islamic-prayer-times

Quick Start

import { calcPrayerTimes, getNextPrayer, METHODS, CITIES, CITIES_BY_COUNTRY } from 'islamic-prayer-times';

// Calculate for a specific city
const riyadh = CITIES.find(c => c.name === 'Riyadh')!;
const today = new Date();

const times = calcPrayerTimes(
  riyadh.lat,    // 24.7136
  riyadh.lng,    // 46.6753
  riyadh.tz,     // 3 (UTC+3)
  '1',           // Umm al-Qra (Saudi)
  today
);

console.log(times);
// { fajr: '04:12', sunrise: '05:36', dhuhr: '12:04', asr: '15:28', maghrib: '18:32', isha: '20:02' }

// Find the next upcoming prayer
const next = getNextPrayer(times, new Date());
console.log(next);
// { name: 'Dhuhr', nameAr: 'الظهر', time: '12:04', diff: 45 }

API

calcPrayerTimes(lat, lng, tz, methodId, date)

Calculates the six daily prayer times for a given location and date.

| Param | Type | Description | |------------|----------|--------------------------------------| | lat | number | Latitude in degrees | | lng | number | Longitude in degrees | | tz | number | UTC offset in hours (e.g. 3 for +3) | | methodId | string | Calculation method key (see METHODS) | | date | Date | The target date |

Returns PrayerTimes:

{
  fajr:    string;  // "HH:MM"
  sunrise: string;
  dhuhr:   string;
  asr:     string;
  maghrib: string;
  isha:    string;
}

getNextPrayer(times, now)

Finds the next prayer that hasn't started yet.

| Param | Type | Description | |--------|--------------|---------------------------| | times | PrayerTimes | The day's prayer times | | now | Date | Current date/time |

Returns NextPrayer | null:

{
  name:   string;   // "Fajr"
  nameAr: string;   // "الفجر"
  time:   string;   // "HH:MM"
  diff:   number;   // minutes until prayer
}

METHODS

A record of 8 calculation methods:

| Key | Name | Fajr Angle | Isha Angle | Isha Offset | |-----|--------------------------|------------|------------|-------------| | 1 | Umm al-Qura (Saudi) | 18.5° | — | 90 min | | 2 | Egyptian Authority | 19.5° | 17.5° | — | | 3 | Muslim World League | 18° | 17° | — | | 4 | Karachi University | 18° | 18° | — | | 5 | ISNA (North America) | 15° | 15° | — | | 6 | Kuwait | 18° | 17.5° | — | | 7 | Qatar | 18° | — | 90 min | | 8 | Singapore | 20° | 18° | — |

Each entry includes ar, en, and tr (Arabic, English, Turkish) display names, plus fajrAngle, ishaAngle, and optional ishaOffset.

CITIES

An array of 80+ cities, each with:

{
  name:   string;   // "Makkah"
  nameAr: string;   // "مكة المكرمة"
  lat:    number;   // 21.3891
  lng:    number;   // 39.8579
  tz:     number;   // 3
}

CITIES_BY_COUNTRY

Cities grouped by ISO 3166-1 alpha-2 country code:

{
  SA: {
    country: 'Saudi Arabia',
    countryAr: 'السعودية',
    cities: [ /* City, ... */ ]
  },
  EG: { ... },
  // ... 50+ countries
}

Types

interface CalculationMethod {
  ar: string;
  en: string;
  tr: string;
  fajrAngle: number;
  ishaAngle: number;
  ishaOffset?: number;
}

interface PrayerTimes {
  fajr: string;
  sunrise: string;
  dhuhr: string;
  asr: string;
  maghrib: string;
  isha: string;
}

interface NextPrayer {
  name: string;
  nameAr: string;
  time: string;
  diff: number;
}

interface City {
  name: string;
  nameAr: string;
  lat: number;
  lng: number;
  tz: number;
}

License

MIT