Persian Modules need to Improved Application.
Collections of Persian Utils And Helpers Function.
- convertDigitsFaToEn
- convertDigitsEnToFa
- persianCardValidation
- timeAgo
- isNationalID
- numericalSeparator
- numericalWithoutSeparator
- wordifyNumbers
- abbNumber
npm install persian-utilities
Import persian-utilities
into your app's modules or import ES modules With Name
import { convertDigitsFaToEn } from 'persian-utilities';
convertDigitsFaToEn('۱۲۳۴'); // result : 1234
import { convertDigitsEnToFa } from 'persian-utilities';
convertDigitsEnToFa('1234'); // result : ۱۲۳۴
import { persianCardValidation } from 'persian-utilities';
persianCardValidation('6219861054512345'); // result : {bankName : "بانک سامان" , isValid : true}
second argument set Exact option
import { timeAgo } from 'persian-utilities';
// not exact mode
timeAgo('۱۴۰۱/۰۵/۰۹ ۱۰:۰۰'); // result : روز قبل 1
// exact mode
timeAgo('۱۴۰۱/۰۵/۰۹ ۱۰:۰۰', true); // result : ثانیه29 و ساعت2 و روز1
import { isNationalID } from 'persian-utilities';
isNationalID('1111111111'); // result : true
import { numericalSeparator } from 'persian-utilities';
numericalSeparator(entryNumber, separateLength?: number, separator?: string)
import { numericalSeparator } from 'persian-utilities';
// without Passing Any Option
numericalSeparator(100000); // result : 100,000
// with Customized options
numericalSeparator('10000', 2, '.'); // result : 1.00.00
index | argument | type | default value |
---|---|---|---|
1 | entryNumber | string or number | - |
2 | separateLength (optional) | number | 3 |
3 | separator (optional) | string | "," |
import { numericalWithoutSeparator } from 'persian-utilities';
numericalWithoutSeparator(numberWithSeparator: string, separator?: string)
import { numericalWithoutSeparator } from 'persian-utilities';
// without Passing Any Option
numericalWithoutSeparator(100000); // result : 100,000
// with Customized options
numericalWithoutSeparator(1.00.00 , "."); // result : 10000
We Supported Entry Number Less Than 1 Trillion
import { wordifynumbers } from 'persian-utilities';
wordifynumbers(5620); // result : پنج هزار و ششصد و بیست
wordifyNumbers(153000); // result : یکصد و پنجاه و سه هزار
wordifyNumbers('۵۲۴۴۲۴۴۳۶۰۰'); // result : پنجاه و دو میلیارد و چهارصد و چهل و دو میلیون و چهارصد و چهل و سه هزار و ششصد
Convert long number into abbreviated string
import { abbNumber } from 'persian-utilities';
abbNumber(5620); // result : "5K"
abbNumber(1530000); // result : "1M"
abbNumber(52100000,1); // result : "52.1M"
number | abbr | name |
---|---|---|
>10^3 | K | kilo |
>10^6 | M | mega |
>10^9 | G | giga |
>10^12 | T | tera |
>10^15 | P | peta |
>10^18 | E | exa |