Package Exports
- arabic-digits
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (arabic-digits) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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-digits
Usage
import {toArabic} from 'arabic-digits';
toArabic(num, intOnly)
Options
options are the same in both 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 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 Old
passing mixed string and parsing it.
import {toArabic} from 'arabic-digits';
toArabic("22 Years Old", true) //٢٢
all the above examples applies on fromArabic
also.