Skip to content

Latest commit

 

History

123 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert Numbers

npm NPM npm npm unpacked size

@smakss/convert-numbers converts Arabic-Indic and Persian digits to English digits while preserving the rest of your text.

Demo

Try the CodeSandbox demo, or run the local playground included in this repository.

Installation

npm install @smakss/convert-numbers
# or
pnpm add @smakss/convert-numbers

Usage

For ECMAScript modules:

import convertNumbers from '@smakss/convert-numbers';

console.log(convertNumbers('۱۲۳۴۵۶۷۸۹۰')); // '1234567890'
console.log(convertNumbers('رقم الطلب: ١٢٣-٤٥٦')); // 'رقم الطلب: 123-456'
console.log(convertNumbers('')); // ''

For CommonJS:

const { default: convertNumbers } = require('@smakss/convert-numbers');

console.log(convertNumbers('٤٥٦')); // '456'

Features

  • Converts Arabic-Indic digits (٠–٩) and Persian digits (۰–۹).
  • Preserves surrounding text, punctuation, spacing, and other digits.
  • Includes ESM, CommonJS, and TypeScript declaration entrypoints.
  • Supports Node.js 18 and later, as well as browsers.

Local playground

The Vite playground imports this package through the pnpm workspace, so you can try local changes without publishing a version:

pnpm install
pnpm run dev:playground

Build the playground with pnpm run build:playground.

Contributing

See CONTRIBUTING.md for development and pull request guidelines.

Code of Conduct

Please read our Code of Conduct before participating.

Releases

Packages

Used by

Contributors

Languages