1.0.4 • Published 2 years ago

persianhelper v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Persian Helper

A package for the Persian programmer community and validation, correction and production of Persian strings or Iranian cases

npm version install size npm bundle size npm downloads jsDeliver

Installing

Package manager

Using npm:

 npm install persianhelper

Using yarn:

 yarn add persianhelper

Usage/Examples

Once the package is installed, you can import the library using import or require approach:

import {
  arabicToPersian,
  isFullName,
  generateNationalCode,
  phoneNumberInfo,
} from "persianhelper";
const persianHelper = require("persianhelper");

Parser :

You can parse Arabic number and characters to Persian number and characters

Character :

Conver Characters

Arabic to Persian :

convert all Arabic characters to Persian Charaters

import { arabicToPersian } from "persianhelper";

arabicToPersian("جُمُعَةِ"); // "جمعه"
arabicToPersian("يحيي ١٤٩"); // "یحیی ۱۴۹"

SwitchKey :

convert all Persian or Arabic Characters to English Character in keyboard

import { switchKey } from "persianhelper";

switchKey("لخخلمث.زخئ"); // "google.com"

HalfSpace :

add half space to the text

import { halfSpace } from "persianhelper";

halfSpace("این متن تست می باشد."); // "این متن تست می‌باشد."

Number :

Parse the number to anything you want

Arabic, Persian to English :

Parse the Persian number to English number

import { numberToEnglish } from "persianhelper";

numberToEnglish("۰۱۲۳۴۵۶۷۸۹"); // "0123456789"

Seperate Number :

Parse the number to price number

import { seperateNumber } from "persianhelper";

seperateNumber("1200000000"); // -> return -> "1,200,000,000"

seperateNumber("۱۳۴۵۲۳۴۴۰"); // "134,523,440"

Number To word :

Parse the Number to Persian word

import { numberToWord } from "persianhelper";

numberToWord(10564523); // "ده میلیون و پانصد و شصت و چهار هزار و پانصد و بیست و سه"

Validation :

You can validate your string and anything this time I added to this package

String Input :

Checking String Input thing

FullName :

Check fullName, If it's valid return true otherwise return false

import { isFullName } from "persianhelper";

isFullName("علی"); // false
isFullName("علی محمدی"); // true

Date Time :

Check Date and Time, If it's valid return true otherwise return false

import { isDate, isTime, isDateTime } from "persianhelper";

isDate("1402/06/20"); // true
isTime("21:06"); // true
isDateTime("1402/06/20 21:06"); // true

Email :

Check Email, If it's valid return true otherwise return false

import { isEmail } from "persianhelper";

isEmail("test@gmail.com"); // true

NationalId NationaCode :

Valid and generate NationalId and NationaCode

Validator :

Check NationalId and NationalCode, If it's valid return true otherwise return false (NationalId for legal entities and NationalCode for real people)

import { isNationalId, isNationalCode } from "persianhelper";

isNationalId("14007650912"); // true
isNationalCode("8497548795"); // true

Generate :

Generate NationalCode

import {
  generateNationalCode,
  generateNationalCodeRound,
  placeOfNationalCode,
} from "persianhelper";

generateNationalCode(); // "8497548795"
generateNationalCodeRound(); // "8000011018"
placeOfNationalCode("442"); // { city: 'یزد', province: 'یزد', codes: [ '442', '443' ] }

Postal Code :

Check PostalCode, If it's valid return province and city of postalCode

import { postalCodeInfo } from "persianhelper";

postalCodeInfo("891");
/*  
{
  code: 891,
  city: 'یزد',
  cityEnglishName: 'Yazd',
  provinceId: 31,
  province: 'یزد',
  originLat: '31.88352203369140',
  originLng: '54.34774017333980'
}
 */

PlateNumber :

Check plateNumber, If it's valid return province and city of postalCode

import { plateNumberInfo } from "persianhelper";

plateNumberInfo({ numbers: "1132144", char: "ج" });
/*  
{
  type: 'Car',
  template: '11ج321ایران44',
  details: {
    firstTwoDigits: '11',
    plateCharacter: 'ج',
    nextThreeDigits: '321',
    provinceCode: '44'
  },
  province: 'تهران',
  category: 'شخصی'
}
 */

PhoneNumber :

Check phoneNumber and If it's valid return province and city of postalCode

import { isPhoneNumber, phoneNumberInfo } from "persianhelper";

isPhoneNumber("09124446677"); // true
phoneNumberInfo("09124446677");
/*  
{
  province: [
    'البرز',
    'زنجان',
    'سمنان',
    'قزوین',
    'قم',
    'برخی از شهرستان های استان مرکزی'
  ],
  base: 'تهران',
  type: [ 'دائمی' ],
  operator: 'همراه اول'
}
 */

Banking :

Check shebaNumber, bankNameCard and If it's valid return bankName and other info

import { shebaNumberInfo, bankNameCard, isShebaNumber } from "persianhelper";

isShebaNumber("IR270170000000100324200001"); // true
bankNameCard("504172"); // "بانک رسالت"
shebaNumberInfo("IR270170000000100324200001");
/*  
{
  code: '017',
  nickname: 'melli',
  name: 'Melli',
  persianName: 'بانک ملی ایران',
  accountNumberAvailable: false
}
 */
1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago