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

anynum

v1.0.0

Published

Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to ASCII numerals. Zero dependencies, performance-first.

Readme

anynum

Normalize Unicode decimal digits and minus signs to ASCII.

Converts digits from any script — Devanagari, Arabic-Indic, Thai, Bengali, Fullwidth, and 50+ others — to their ASCII equivalents (09). Also normalizes Unicode minus variants (, , ) to ASCII -.

Pairs naturally with strnum — use anynum to normalize first, then strnum to detect the numeric type.

import anynum from 'anynum';

anynum('१२.३४')     // → '12.34'   (Devanagari)
anynum('٣٫١٤')     // → '3.14'    (Arabic-Indic)
anynum('−४२')      // → '-42'     (Unicode minus + Devanagari)
anynum('-99.5') // → '-99.5'   (Fullwidth minus + Fullwidth digits)
anynum('hello')    // → 'hello'   (no digits — zero allocation)
anynum('100')      // → '100'     (already ASCII — zero allocation)

Install

npm install anynum

Usage

// ESM
import anynum from 'anynum';
import { anynum } from 'anynum';

API

anynum(str: string): string
  • Accepts a string, returns a string.
  • Non-string values are returned as-is (no throw).
  • Non-digit characters pass through unchanged.
  • If no conversion is needed, the original string is returned (zero allocation).

What gets converted

Decimal digits

Any Unicode character in category Nd (decimal digit) is mapped to its ASCII equivalent. This covers all positional decimal digit scripts — every script whose digits represent 09 by position.

anynum('๑๒๓')   // Thai        → '123'
anynum('੧੨੩')   // Gurmukhi   → '123'
anynum('᠑᠒᠓')   // Mongolian  → '123'
anynum('𝟏𝟐𝟑')   // Math Bold  → '123'

Unicode minus variants

Three Unicode characters are normalized to ASCII - (U+002D):

| Code point | Character | Name | |---|---|---| | U+2212 | | MINUS SIGN (mathematical) | | U+FF0D | | FULLWIDTH HYPHEN-MINUS | | U+FE63 | | SMALL HYPHEN-MINUS |

Dashes used for punctuation — EN DASH (), EM DASH (), HYPHEN () — are intentionally not converted.

anynum('−42')   // U+2212 MINUS SIGN      → '-42'
anynum('-42')  // U+FF0D FULLWIDTH        → '-42'
anynum('–42')   // U+2013 EN DASH          → '–42'  (unchanged)

Use with strnum

anynum and strnum compose cleanly:

import anynum from 'anynum';
import strnum from 'strnum';

strnum(anynum('१२.३४'))   // → 12.34  (number, float)
strnum(anynum('−४२'))     // → '-42'  (string; strnum handles sign detection)
strnum(anynum('hello'))   // → 'hello'

Supported scripts

50+ decimal digit scripts from Unicode Nd category, including:

| Script | Zero | Sample | |---|---|---| | Devanagari (Hindi/Marathi/Nepali) | U+0966 | ०१२३४५६७८९ | | Arabic-Indic | U+0660 | ٠١٢٣٤٥٦٧٨٩ | | Extended Arabic-Indic (Urdu/Persian) | U+06F0 | ۰۱۲۳۴۵۶۷۸۹ | | Bengali | U+09E6 | ০১২৩৪৫৬৭৮৯ | | Gurmukhi | U+0A66 | ੦੧੨੩੪੫੬੭੮੯ | | Gujarati | U+0AE6 | ૦૧૨૩૪૫૬૭૮૯ | | Odia | U+0B66 | ୦୧୨୩୪୫୬୭୮୯ | | Tamil | U+0BE6 | ௦௧௨௩௪௫௬௭௮௯ | | Telugu | U+0C66 | ౦౧౨౩౪౫౬౭౮౯ | | Kannada | U+0CE6 | ೦೧೨೩೪೫೬೭೮೯ | | Malayalam | U+0D66 | ൦൧൨൩൪൫൬൭൮൯ | | Thai | U+0E50 | ๐๑๒๓๔๕๖๗๘๙ | | Lao | U+0ED0 | ໐໑໒໓໔໕໖໗໘໙ | | Tibetan | U+0F20 | ༠༡༢༣༤༥༦༧༨༩ | | Myanmar | U+1040 | ၀၁၂၃၄၅၆၇၈၉ | | Khmer | U+17E0 | ០១២៣៤៥៦៧៨៩ | | Mongolian | U+1810 | ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙ | | Fullwidth (CJK context) | U+FF10 | 0123456789 | | Mathematical Bold | U+1D7CE | 𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗 | | Adlam | U+1E950 | 𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙 | | … and 30+ more | | |


What it does NOT convert

  • Kanji/Chinese numeral words (, , ) — these are ideographic numerals, not decimal digits. Each language has its own positional system requiring separate parsing logic.
  • Roman numerals (, ) — not decimal digits.
  • Punctuation dashes ( EN, EM, HYPHEN) — not numeric signs.
  • Decimal separators — commas, periods, Arabic decimal comma (٫) are passed through as-is. Separator normalization is the caller's responsibility.

License

MIT