Options
All
  • Public
  • Public/Protected
  • All
Menu

arabic-to-persian

Build Status Coverage Status PRs Welcome

arabic-to-persian is a library to convert arabic text to persian.

Install

npm install arabic-to-persian

or

yarn add arabic-to-persian

Usage

In most cases you just need to import convert function as bellow:

import { convert } from "arabic-to-persian";

const arabic = "ﻭاﮊﻩ";

const persian = "واژه";

console.log(arabic === persian); // false

console.log(convert(arabic) === persian); // true

convert accepts another argument as options. In this example you can see how it's possible to set your own charMap:

import { convert } from "arabic-to-persian";

const arabic = "ï·¼";

const persian = "ریال";

console.log(arabic === persian); // false

console.log(convert(arabic) === persian); // false

function customConvert(text) {
  const options = { charMap: {} };
  options.charMap[arabic] = persian;
  return convert(text, options);
}

console.log(customConvert(arabic) === persian); // true

A better way to create your own converter is createConverter closure:

import { createConverter } from "arabic-to-persian";

const arabic = "ï·¼";

const persian = "ریال";

console.log(arabic === persian); // false

const options = { charMap: {} };
options.charMap[arabic] = persian;
const ar2fa = createConverter(options)

console.log(ar2fa(arabic) === persian); // true

Api

See documentation

Contributing

See contributing guide

Index

Type aliases

Char

Char: string

CharMap

CharMap: object

Type declaration

  • [key: string]: string

DefaultValue

DefaultValue: function

Type declaration

    • Parameters

      Returns string

UnicodeMap

UnicodeMap: object

Type declaration

  • [key: string]: string

Functions

convert

  • convert(text: string, options?: Options): string

createConverter

  • createConverter(options?: Options): (Anonymous function)

replaceByCharMap

  • replaceByCharMap(text: string, map: CharMap): string

replaceByUnicodeMap

replaceMultiSpacesWithSingleSpace

  • replaceMultiSpacesWithSingleSpace(text: string): string

unicodeOf

  • unicodeOf(c: string): string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc