arabic-digits
v1.1.0
Published
A light-weight utility to convert arabic digits to english or modern digits and vice versa.
Downloads
633
Maintainers
Readme
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-digitsUsage
import {toArabic} from 'arabic-digits';
toArabic(num, intOnly)Options
options are the same in both methods.
num: stringa string containing the number to be converted. in toArabic method this parameter could be string | number.
intOnly: booleanif true the method will remove any other character that is not a digit.
Eamples
passing number.
import {toArabic} from 'arabic-digits';
toArabic(2020) //٢٠٢٠passing string.
import {toArabic} from 'arabic-digits';
toArabic("2020") //٢٠٢٠passing mixed string.
import {toArabic} from 'arabic-digits';
toArabic("22 Years Old") //٢٢ Years Oldpassing mixed string and parsing it.
import {toArabic} from 'arabic-digits';
toArabic("22 Years Old", true) //٢٢all the above examples applies on fromArabic also.
