Skip to content

faressoft/arabic-digits

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A light-weight utility to convert arabic digits to english or modern digits and vice versa. the library contains two methods toArabic, and fromArabic.

Installation

$ npm i arabic-digits // or yarn or pnpm

Usage

import {toArabic} from 'arabic-digits';

toArabic(num, intOnly)

Options

options applies to the two methods.

num: string

a string containing the number to be converted. in toArabic method this parameter could be string | number.

intOnly: boolean

if true the method will remove any other character that is not a digit.

Eamples

passing a number.

import {toArabic} from 'arabic-digits';

toArabic(2020) //٢٠٢٠

passing a string.

import {toArabic} from 'arabic-digits';

toArabic("2020") //٢٠٢٠

passing a mixed string.

import {toArabic} from 'arabic-digits';

toArabic("22 Years Old") //٢٢ Years Old

passing a mixed string with parsing.

import {toArabic} from 'arabic-digits';

toArabic("22 Years Old", true) //٢٢

all the above examples applies to fromArabic also.

About

A light-weight utility to convert Arabic digits to English or modern digits and vice versa.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 65.6%
  • JavaScript 34.4%