persian-utilities
v1.1.1
Published
Persian utilities using for persian application lang UTF8
Downloads
19
Maintainers
Readme
persian-utilities
Persian Modules need to Improved Application. Collections of Persian Utils And Helpers Function.
Collections
- convertDigitsFaToEn
- convertDigitsEnToFa
- persianCardValidation
- timeAgo
- isNationalID
- numericalSeparator
- numericalWithoutSeparator
- wordifyNumbers
- abbNumber
Install
NPM
npm install persian-utilities
Usage
Import persian-utilities
into your app's modules or import ES modules With Name
Apis
convertDigitsFaToEn
import { convertDigitsFaToEn } from 'persian-utilities';
convertDigitsFaToEn('۱۲۳۴'); // result : 1234
convertDigitsEnToFa
import { convertDigitsEnToFa } from 'persian-utilities';
convertDigitsEnToFa('1234'); // result : ۱۲۳۴
persianCardValidation
import { persianCardValidation } from 'persian-utilities';
persianCardValidation('6219861054512345'); // result : {bankName : "بانک سامان" , isValid : true}
timeAgo
second argument set Exact option
import { timeAgo } from 'persian-utilities';
// not exact mode
timeAgo('۱۴۰۱/۰۵/۰۹ ۱۰:۰۰'); // result : روز قبل 1
// exact mode
timeAgo('۱۴۰۱/۰۵/۰۹ ۱۰:۰۰', true); // result : ثانیه29 و ساعت2 و روز1
isNationalID
import { isNationalID } from 'persian-utilities';
isNationalID('1111111111'); // result : true
numericalSeparator
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
numericalSeparator Arguments
| index | argument | type | default value | | ----- | ------------------------- | ---------------- | ------------- | | 1 | entryNumber | string or number | - | | 2 | separateLength (optional) | number | 3 | | 3 | separator (optional) | string | "," |
numericalWithoutSeparator
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
wordifynumbers
We Supported Entry Number Less Than 1 Trillion
import { wordifynumbers } from 'persian-utilities';
wordifynumbers(5620); // result : پنج هزار و ششصد و بیست
wordifyNumbers(153000); // result : یکصد و پنجاه و سه هزار
wordifyNumbers('۵۲۴۴۲۴۴۳۶۰۰'); // result : پنجاه و دو میلیارد و چهارصد و چهل و دو میلیون و چهارصد و چهل و سه هزار و ششصد
abbNumber
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"
Large number abbreviations
| 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 |