a lightweight library for projects that allow you to parse the digits inside of your strings to persian and vice versa.
run one of these commends on your project root:
npm install persian-digit-tools --save
yarn add persian-digit-tools
bower install persian-digit-tools --save
first, you must import it
var convertor = require('persian-digit-tools').DigitConvertor;
import { DigitConvertor } from 'persian-digit-tools';
then you can use it like this:
let str = 'hello 123.sda31 this1233is a complex 1';
console.log(convertor.toPersian(str)); // it will print 'hello ۱۲۳.sda۳۱ this۱۲۳۳is a complex ۱'
let str = '۱۲۳۴۵۶ ۳۲۱۳ ۶۴۱۲۳,۲۳۱';
console.log(convertor.toEnglish(str)); // it will print '123456 3213 64123,231'
you can see test inside of test folder and for run tests use this command:
npm run test
feel free to fork and do what ever you want (or send pull requests).
for contribute this project, first clone the project and go to project folder:
git clone https://github.com/MetaiR/persian-digit-tools.git
cd persian-digit-tools
then run:
npm install
after that you ready to go :D