{
  "_id": "anynum",
  "maintainers": [
    {
      "name": "amitgupta",
      "email": "amitgupta.gwl@gmail.com"
    }
  ],
  "keywords": [
    "unicode",
    "digits",
    "normalize",
    "devanagari",
    "arabic",
    "hindi",
    "japanese",
    "indic",
    "asian",
    "math",
    "numerals",
    "strnum"
  ],
  "dist-tags": {
    "latest": "1.0.1"
  },
  "author": {
    "name": "Amit Gupta",
    "url": "https://solothought.work/"
  },
  "_rev": "2-5a075c17bf8b1a2d9b81b56767411682",
  "description": "Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to ASCII numerals. Zero dependencies, performance-first.",
  "readme": "# anynum\n\nNormalize Unicode decimal digits and minus signs to ASCII.\n\nConverts digits from any script — Devanagari, Arabic-Indic, Thai, Bengali, Fullwidth, and [50+ others](#supported-scripts) — to their ASCII equivalents (`0`–`9`). Also normalizes Unicode minus variants (`−`, `－`, `﹣`) to ASCII `-`.\n\nPairs naturally with [`strnum`](https://github.com/nicolo-ribaudo/strnum) — use `anynum` to normalize first, then `strnum` to detect the numeric type.\n\n```js\nimport anynum from 'anynum';\n\nanynum('१२.३४')     // → '12.34'   (Devanagari)\nanynum('٣٫١٤')     // → '3.14'    (Arabic-Indic)\nanynum('−४२')      // → '-42'     (Unicode minus + Devanagari)\nanynum('－９９.５') // → '-99.5'   (Fullwidth minus + Fullwidth digits)\nanynum('hello')    // → 'hello'   (no digits — zero allocation)\nanynum('100')      // → '100'     (already ASCII — zero allocation)\n```\n\n---\n\n## Install\n\n```bash\nnpm install anynum\n```\n\n---\n\n## Usage\n\n```js\n// ESM\nimport anynum from 'anynum';\nimport { anynum } from 'anynum';\n\n```\n\n### API\n\n```ts\nanynum(str: string): string\n```\n\n- Accepts a `string`, returns a `string`.\n- Non-string values are returned as-is (no throw).\n- Non-digit characters pass through unchanged.\n- If no conversion is needed, the **original string is returned** (zero allocation).\n\n---\n\n## What gets converted\n\n### Decimal digits\n\nAny 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 `0`–`9` by position.\n\n```js\nanynum('๑๒๓')   // Thai        → '123'\nanynum('੧੨੩')   // Gurmukhi   → '123'\nanynum('᠑᠒᠓')   // Mongolian  → '123'\nanynum('𝟏𝟐𝟑')   // Math Bold  → '123'\n```\n\n### Unicode minus variants\n\nThree Unicode characters are normalized to ASCII `-` (`U+002D`):\n\n| Code point | Character | Name |\n|---|---|---|\n| `U+2212` | `−` | MINUS SIGN (mathematical) |\n| `U+FF0D` | `－` | FULLWIDTH HYPHEN-MINUS |\n| `U+FE63` | `﹣` | SMALL HYPHEN-MINUS |\n\nDashes used for punctuation — EN DASH (`–`), EM DASH (`—`), HYPHEN (`‐`) — are intentionally **not** converted.\n\n```js\nanynum('−42')   // U+2212 MINUS SIGN      → '-42'\nanynum('－42')  // U+FF0D FULLWIDTH        → '-42'\nanynum('–42')   // U+2013 EN DASH          → '–42'  (unchanged)\n```\n\n---\n\n## Use with strnum\n\n`anynum` and `strnum` compose cleanly:\n\n```js\nimport anynum from 'anynum';\nimport strnum from 'strnum';\n\nstrnum(anynum('१२.३४'))   // → 12.34  (number, float)\nstrnum(anynum('−४२'))     // → '-42'  (string; strnum handles sign detection)\nstrnum(anynum('hello'))   // → 'hello'\n```\n\n---\n\n\n## Supported scripts\n\n50+ decimal digit scripts from Unicode `Nd` category, including:\n\n| Script | Zero | Sample |\n|---|---|---|\n| Devanagari (Hindi/Marathi/Nepali) | `U+0966` | `०१२३४५६७८९` |\n| Arabic-Indic | `U+0660` | `٠١٢٣٤٥٦٧٨٩` |\n| Extended Arabic-Indic (Urdu/Persian) | `U+06F0` | `۰۱۲۳۴۵۶۷۸۹` |\n| Bengali | `U+09E6` | `০১২৩৪৫৬৭৮৯` |\n| Gurmukhi | `U+0A66` | `੦੧੨੩੪੫੬੭੮੯` |\n| Gujarati | `U+0AE6` | `૦૧૨૩૪૫૬૭૮૯` |\n| Odia | `U+0B66` | `୦୧୨୩୪୫୬୭୮୯` |\n| Tamil | `U+0BE6` | `௦௧௨௩௪௫௬௭௮௯` |\n| Telugu | `U+0C66` | `౦౧౨౩౪౫౬౭౮౯` |\n| Kannada | `U+0CE6` | `೦೧೨೩೪೫೬೭೮೯` |\n| Malayalam | `U+0D66` | `൦൧൨൩൪൫൬൭൮൯` |\n| Thai | `U+0E50` | `๐๑๒๓๔๕๖๗๘๙` |\n| Lao | `U+0ED0` | `໐໑໒໓໔໕໖໗໘໙` |\n| Tibetan | `U+0F20` | `༠༡༢༣༤༥༦༧༨༩` |\n| Myanmar | `U+1040` | `၀၁၂၃၄၅၆၇၈၉` |\n| Khmer | `U+17E0` | `០១២៣៤៥៦៧៨៩` |\n| Mongolian | `U+1810` | `᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙` |\n| Fullwidth (CJK context) | `U+FF10` | `０１２３４５６７８９` |\n| Mathematical Bold | `U+1D7CE` | `𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗` |\n| Adlam | `U+1E950` | `𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙` |\n| … and 30+ more | | |\n\n---\n\n## What it does NOT convert\n\n- **Kanji/Chinese numeral words** (`三`, `百`, `万`) — these are ideographic numerals, not decimal digits. Each language has its own positional system requiring separate parsing logic.\n- **Roman numerals** (`Ⅳ`, `Ⅻ`) — not decimal digits.\n- **Punctuation dashes** (`–` EN, `—` EM, `‐` HYPHEN) — not numeric signs.\n- **Decimal separators** — commas, periods, Arabic decimal comma (`٫`) are passed through as-is. Separator normalization is the caller's responsibility.\n\n---\n\n## License\n\nMIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/NaturalIntelligence/anynum.git"
  },
  "bugs": {
    "url": "https://github.com/NaturalIntelligence/anynum/issues"
  },
  "license": "MIT",
  "versions": {
    "1.0.0": {
      "name": "anynum",
      "version": "1.0.0",
      "keywords": [
        "unicode",
        "digits",
        "normalize",
        "devanagari",
        "arabic",
        "hindi",
        "japanese",
        "indic",
        "asian",
        "math",
        "numerals",
        "strnum"
      ],
      "author": {
        "url": "https://solothought.work/",
        "name": "Amit Gupta"
      },
      "license": "MIT",
      "_id": "anynum@1.0.0",
      "maintainers": [
        {
          "name": "amitgupta",
          "email": "amitgupta.gwl@gmail.com"
        }
      ],
      "homepage": "https://github.com/NaturalIntelligence/anynum#readme",
      "bugs": {
        "url": "https://github.com/NaturalIntelligence/anynum/issues"
      },
      "dist": {
        "shasum": "afe3f3a78c6621fbdf1e107154fac01eef711cc5",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/anynum/-/anynum-1.0.0.tgz",
        "fileCount": 5,
        "integrity": "sha512-xjR9/zBVnUOP6ztMIIgShjsxui80nQUQH+5xJnvrYLs+90bF25/KJqaAi8mk+B4RDtX1Nspi6fmp4YTEts8SfA==",
        "signatures": [
          {
            "sig": "MEQCIATOITujlRaig8k3sc83/77C5vGoJSm6NClnZLCG6kDGAiA9y8uYxzpTPFwx5EB0yhsXwRuyH07vGFGL/mRvwiTE0w==",
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
          }
        ],
        "unpackedSize": 16049
      },
      "main": "./anynum.js",
      "type": "module",
      "funding": [
        {
          "url": "https://github.com/sponsors/NaturalIntelligence",
          "type": "github"
        }
      ],
      "gitHead": "adbfa0f200712520dea86304f0e5afc914984c5e",
      "scripts": {
        "test": "jasmine tests/anynum.test.js",
        "bench": "node test/bench.js"
      },
      "_npmUser": {
        "name": "amitgupta",
        "email": "amitgupta.gwl@gmail.com"
      },
      "repository": {
        "url": "git+https://github.com/NaturalIntelligence/anynum.git",
        "type": "git"
      },
      "_npmVersion": "11.11.0",
      "description": "Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to ASCII numerals. Zero dependencies, performance-first.",
      "directories": {},
      "_nodeVersion": "22.14.0",
      "_hasShrinkwrap": false,
      "_npmOperationalInternal": {
        "tmp": "tmp/anynum_1.0.0_1780979691382_0.7035571313192337",
        "host": "s3://npm-registry-packages-npm-production"
      }
    },
    "1.0.1": {
      "name": "anynum",
      "version": "1.0.1",
      "description": "Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to ASCII numerals. Zero dependencies, performance-first.",
      "type": "module",
      "main": "./anynum.js",
      "scripts": {
        "test": "jasmine tests/anynum.test.js",
        "bench": "node test/bench.js"
      },
      "keywords": [
        "unicode",
        "digits",
        "normalize",
        "devanagari",
        "arabic",
        "hindi",
        "japanese",
        "indic",
        "asian",
        "math",
        "numerals",
        "strnum"
      ],
      "repository": {
        "type": "git",
        "url": "git+https://github.com/NaturalIntelligence/anynum.git"
      },
      "author": {
        "name": "Amit Gupta",
        "url": "https://solothought.work/"
      },
      "license": "MIT",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/NaturalIntelligence"
        }
      ],
      "gitHead": "996c4711809427963104d717c1bd77383c8f0124",
      "_id": "anynum@1.0.1",
      "bugs": {
        "url": "https://github.com/NaturalIntelligence/anynum/issues"
      },
      "homepage": "https://github.com/NaturalIntelligence/anynum#readme",
      "_nodeVersion": "22.14.0",
      "_npmVersion": "11.11.0",
      "dist": {
        "integrity": "sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==",
        "shasum": "2aac00e08dfad3726c1d462e60dbc2f831659a44",
        "tarball": "https://archive.ito.gov.ir/npm/_packages/anynum/-/anynum-1.0.1.tgz",
        "fileCount": 5,
        "unpackedSize": 16050,
        "signatures": [
          {
            "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
            "sig": "MEYCIQCrAxVfG35PY/OqLK5iO6T99n5EwtIjmNFtaRkua0HIxgIhAK8KtpIVUwVCl/gnur+9uQlBwCdWSgfQRfHVh+6RM/T4"
          }
        ]
      },
      "_npmUser": {
        "name": "amitgupta",
        "email": "amitgupta.gwl@gmail.com"
      },
      "directories": {},
      "maintainers": [
        {
          "name": "amitgupta",
          "email": "amitgupta.gwl@gmail.com"
        }
      ],
      "_npmOperationalInternal": {
        "host": "s3://npm-registry-packages-npm-production",
        "tmp": "tmp/anynum_1.0.1_1781776814661_0.9292698240412793"
      },
      "_hasShrinkwrap": false
    }
  },
  "name": "anynum",
  "time": {
    "created": "2026-06-09T04:34:51.343Z",
    "modified": "2026-07-15T20:16:00.108Z",
    "1.0.0": "2026-06-09T04:34:51.511Z",
    "1.0.1": "2026-06-18T10:00:14.796Z"
  },
  "readmeFilename": "README.md",
  "homepage": "https://github.com/NaturalIntelligence/anynum#readme"
}