Options
All
  • Public
  • Public/Protected
  • All
Menu

Persian Tools - v3.5.2

Index

Other Type Aliases

DigitsConverter<I, O>: ((value: I) => O)

Type Parameters

  • I = string

  • O = string

Type declaration

    • (value: I): O
    • Parameters

      • value: I

      Returns O

ShebaMapCodes: Record<string, ShebaResult>

Plate Type Aliases

PlateOptions: string | PlateApi
PlateResultApiTypeString: keyof typeof PlateTypes

Variables

acceptableKeywords: RegExp = ...

Acceptable keywords between numbers are:

  1. Star -> *
  2. Underscore -> _
  3. Dash -> -
  4. Dot -> .
example:

5022*2910_7087-3466

constant
cardNumberRegex: RegExp = ...

This Regex can find all kind of Iranian Banks' card number into a text such as these models:

  1. 6219-8610-3452-9007
  2. 5022291070873466
  3. ۵۰۲۲۲۹۱۰۸۱۸۷۳۴۶۶
  4. ۵۰۲۲-۲۹۱۰-۷۰۸۷-۳۴۶۶
  5. ۵۰۲۲.۲۹۱۰.۷۰۸۷.۳۴۶۶
  6. ۵۰۲۲_۲۹۱۰_۷۰۸۷_۳۴۶۶
  7. ۵۰۲۲۲۹۱۰۷۰۸۷*۳۴۶۶
constant
shebaMapCodes: ShebaMapCodes = ...
shebaPattern: RegExp = ...
since

v1.4.2

shebaPatternCode: RegExp = ...
since

v1.4.2

Bank account Functions

  • getBankNameFromCardNumber(digits?: string | number): string | null | undefined
  • Find Bank's name by card number

    method

    getBankNameFromCardNumber

    Parameters

    • Optional digits: string | number

      Card number

    Returns string | null | undefined

    string | null | undefined

  • verifyCardNumber(digits: number): boolean | undefined
  • description

    Verify Iranian Bank's card number which is valid or not

    method

    verifyCardNumber

    Parameters

    • digits: number

      card number

    Returns boolean | undefined

Digits Functions

  • digitsArToEn(value: string): string
  • digitsArToEn

    description

    Takes a string and returns a string that represents the same value but its arabic digits are replaced with english digits

    Parameters

    • value: string

    Returns string

  • digitsArToFa(value: string): string
  • digitsArToFa

    description

    Takes a string and returns a string that represents the same value but its arabic digits are replaced with farsi digits

    Parameters

    • value: string

    Returns string

  • digitsEnToAr(value: string | number): string
  • digitsEnToAr

    description

    Takes a string or number and returns a string that represents the same value but its english digits are replaced with arabic digits

    Parameters

    • value: string | number

    Returns string

  • digitsEnToFa(value: string | number): string
  • digitsEnToFa

    description

    Takes a string or number and returns a string that represents the same value but its english digits are replaced with farsi digits

    Parameters

    • value: string | number

    Returns string

  • digitsFaToAr(value: string): string
  • digitsFaToAr

    description

    Takes a string and returns a string that represents the same value but its farsi digits are replaced with arabic digits

    Parameters

    • value: string

    Returns string

  • digitsFaToEn(value: string): string
  • digitsFaToEn

    description

    Takes a string and returns a string that represents the same value but its farsi digits are replaced with english digits

    Parameters

    • value: string

    Returns string

Legal id Functions

  • verifyIranianLegalId(legalId: string | number): boolean | undefined

National id Functions

  • Get Province and City name by Iranian National-Id

    method

    getPlaceByIranNationalId

    Parameters

    • Optional nationalId: string

      string of national id - like this: 1111111111

    Returns IPlaceByNationalId | null | undefined

    If nationalId is valid, function returns an object of details, but if nationalId is invalid, return an error message

  • verifyIranianNationalId(nationalId?: string | number): boolean | undefined
  • Check National-id validation

    method

    verifyIranianNationalId

    Parameters

    • Optional nationalId: string | number

    Returns boolean | undefined

    [valid or no]

Number conversion Functions

Other Functions

  • SortText<T>(str: T | T[]): T[]
  • SortText

    description

    Takes a piece of text in Persian which contains several lines (separated by the newline character), and sorts the lines alphabetically, with respect to their first character.

    deprecated

    This function will be removed in the next release and please don't use this function.

    Type Parameters

    • T extends string

    Parameters

    • str: T | T[]

      a String or a list of strings

    Returns T[]

  • URLfix(url?: string, separator?: string): string | undefined
  • addCommas(number: string | number): string
  • Add Commas to numbers

    method

    addCommas

    Parameters

    • number: string | number

    Returns string

    string of separated numbers by commas, eg: 30,000

  • addOrdinalSuffix(number?: string): string
  • findCapitalByProvince(state: string): string
  • halfSpace(str: string): string
  • Replace halfSpace in string(Zero-width non-joiner)

    method

    halfSpace

    Parameters

    • str: string

    Returns string

    clean entered persian string

  • hasArabic(str: string): boolean
  • Check if string includes Arabic alphabet.

    Parameters

    • str: string

    Returns boolean

    Return true if the entered string includes persian characters

  • hasPersian(str: string, isComplex?: boolean): boolean
  • Check if string includes persian alphabet.

    Parameters

    • str: string
    • isComplex: boolean = false

      in complex mode, we accept some specific characters which are common in Farsi text.

    Returns boolean

    Return true if the entered string includes persian characters

  • isArabic(str: string, trimPattern?: RegExp): boolean
  • Check if string is Arabic

    Parameters

    • str: string
    • trimPattern: RegExp = ...

      Pattern of characters which you want to trim from the string e.g. "-+. ()"

    Returns boolean

    Return true if the entered string does not include other-language characters.

  • isPersian(str: string, isComplex?: boolean, trimPattern?: RegExp): boolean
  • Check if string is in persian.

    Parameters

    • str: string
    • isComplex: boolean = false

      in complex mode, we accept some specific characters which are common in Farsi text.

    • trimPattern: RegExp = ...

      Pattern of characters which you want to trim from the string e.g. "-+. ()"

    Returns boolean

    Return true if the entered string does not include other-language characters.

  • isShebaValid(shebaCode: string): boolean
  • remainingTime(date: string | number | Date): RemainingTime & ToString & IsFinished
  • removeCommas(str: string): number
  • Remove all commas in string

    Parameters

    • str: string

    Returns number

    A number which includes any commas

  • removeOrdinalSuffix(word: string): undefined | string
  • description

    Remove Ordinal suffix in words

    function

    removeOrdinalSuffix

    example

    removeOrdinalSuffix("سه هزارم") // سه هزار removeOrdinalSuffix("سه هزارمین") // سه هزار

    Parameters

    • word: string

      String that includes ordinal suffix

    Returns undefined | string

    A string of words that not includes Ordinal strings

  • shebaIso7064Mod97(iban: string): number
  • toPersianChars(str: string): string | undefined
  • toPersianChars

    Description: Replace all instances of ي and ك with ی and ک, respectively. It should not make any changes to an Arabic text surrounded by appropriate templates.

    method

    toPersianChars

    Parameters

    • str: string

    Returns string | undefined

    cleaned characters of arabic characters

Phone number Functions

  • Find information such as Province, type and model of mobile number. This function is related to the phoneNumberValidator function to detect that the mobile number is valid or not If the Mobile number was valid, then the OperatorModel will be resolved if it was existed. To get more information about phone numbers operators' details, referer to Wikipedia

    example

    phoneNumberDetail("9123456789")

    Parameters

    • mobile: string

    Returns OperatorModel | null

    OperatorModel | null

  • phoneNumberNormalizer(phoneNumber: string, token: "0" | "+98"): string
  • Normalize a phone number to a standard format based on the provided token. This function is related to the phoneNumberValidator function to detect that the mobile number is valid or not

    example

    phoneNumberNormalizer("+989022002580", "0"); // 09022002580 phoneNumberNormalizer("989022002580", "0"); // 09022002580 phoneNumberNormalizer("09022002580", "0"); // 09022002580 phoneNumberNormalizer("09022002580", "+98"); //+989022002580 phoneNumberNormalizer("09802002580", "0"); // Error : this is not valid phone number

    Parameters

    • phoneNumber: string
    • token: "0" | "+98"

      can be either +98 or 0

    Returns string

    String | never

  • phoneNumberValidator(mobile: string): boolean

timeAgo Functions

  • timeAgo(datetime?: string): string
  • Converting Jalali date-time into a time ago.

    Parameters

    • datetime: string = ""

      Format must be yyyy/mm/dd hh:mm:ss. If no value is entered for input, the current time is considered.

    Returns string

    Return time ago value. Eg: حدود 1 سال قبل

Generated using TypeDoc