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

arabic-normalize

v1.0.1

Published

Normalise Arabic script for comparison: diacritics, Quranic pause marks, Persian and Urdu letter variants. Zero dependencies.

Readme

arabic-normalize

Normalise Arabic script for comparison, not for display.

CI TypeScript Dependencies


The problem

A speech model returns علی. The source has علي. Identical to the ear — two different strings to ===. The match rate collapses although the speaker was right.

The same happens with harakat (بِسْمِ vs. بسم), with Quranic pause marks, with Alef variants (آ أ إ ٱ), with Urdu Heh, with tatweel and with Arabic-Indic digits. Every one of these differences is invisible to a human and fatal to a comparison.

This library clears them away in stages, so you decide how far the levelling is allowed to go.

For comparison only. The normalised text is deliberately no longer correctly typeset. What you display is always the original.

Install

npm install arabic-normalize

No dependencies. ESM. TypeScript types included.

Usage

import { normalizeArabic, tokenize, similarity, equals } from "arabic-normalize";

normalizeArabic("بِسْمِ ٱللَّهِ");   // → "بسم الله"
equals("علی", "علي");                // → true  (Farsi Yeh = Arabic Yeh)
equals("کتاب", "كتاب");              // → true  (Keheh = Kaf)

similarity("الحمد لله رب العالمين",
           "الحمد لله رب الناس");    // → 0.75

Options

Every stage can be switched off on its own:

normalizeArabic(text, {
  stripHarakat: true,       // remove vowel marks
  stripQuranicMarks: true,  // recitation and pause marks (U+06D6–U+06ED)
  unifyLetters: true,       // unify regional variants
  normalizeDigits: true,    // ٠-٩ and ۰-۹ to ASCII
  collapseWhitespace: true, // collapse runs of whitespace
});

Why similarity scores leniently

It compares the Levenshtein distance of word sequences, not exact equality. A single differing word in a long verse does not drag the result to zero.

That is a product decision, not a mathematical one: in a recitation check a strict comparison is useless to a learner — it only ever says "wrong", never "almost".

The trap tokenize solves

A naive split(/\s+/) breaks on Quranic Uthmani text. Some editions carry free-standing waqf markers: a pause mark with a space on either side. Strip the mark and an empty string is left in the array, shifting every following word index by one.

What hangs off that: word-level timestamps for audio sync, highlighting the current word, every mapping between text and sound. The defect stays invisible until the highlight drifts apart mid-verse.

"الحمد ۖ لله".split(/\s+/);  // → ["الحمد", "ۖ", "لله"]   after strip: ["الحمد", "", "لله"]
tokenize("الحمد ۖ لله");      // → ["الحمد", "لله"]

Coverage

| Category | Example | Result | |---|---|---| | Harakat | بِسْمِ | بسم | | Quranic marks | الحمدۖ | الحمد | | Farsi/Urdu Yeh | ی ى ے | ي | | Keheh / Swash Kaf | ک ڪ | ك | | Urdu Heh | ہ ۃ | ه | | Alef variants | آ أ إ ٱ | ا | | Hamza carriers | ؤ ئ | و ي | | Teh Marbuta | ة | ه | | Tatweel | كــتــاب | كتاب | | Digits | ٢٠٢٦ ۲۰۲۶ | 2026 |

Order of the steps

Deliberate, not arbitrary:

  1. NFC: unify Unicode composition
  2. Strip marks: Quranic marks, then harakat, then tatweel
  3. Map letters: regional variants
  4. Digits, then whitespace

The other way round, combinations survive that would no longer be recognisable as combinations after the letter mapping.

Development

npm install
npm test        # 23 tests
npm run typecheck
npm run build

Licence

MIT © Domenic Moran