Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 1.76 KB

README.md

File metadata and controls

69 lines (57 loc) · 1.76 KB

number to persian text converter

This NodeJs library enables you to create formal Farsi spoken format for numbers that represent an amount in Rials (IRR).

install

using npm :

$ npm install iramount --save

Usage

const irAmount = require("iramount"); 
const amount = new irAmount(10239876); // constructor just accepts number 

Grouping Digits

To group digits by three, use

const withDigitGrouping = amount.digitGrouped(); // returns 10,239,876

params :

  • formatType | default = "R" | R = Rial and T = Toman
  • language | default = "EN" | EN = English and Fa = Farsi
  • groupDigitBy | default = 3
  • amount | constructor value

for Ex :

const withDigitGrouping = amount.digitGrouped("R", "Fa"); // returns ۱۰,۲۳۹,۸۷۶

or

const withDigitGrouping = amount.digitGrouped("T", "Fa", 2); // returns ۱,۰۲,۳۹,۸۷.۶

Convert To Text

To display Farsi spoken format in Rials (IRR), use

const rialFormat = amount.farsiFormatRial(); // returns ده میلیون و دویست و سی و نه هزار و هشتصد و هفتاد و شش ریال

To display Farsi spoken format in Tomans (Toman), use

const tomanFormat = amount.farsiFormatToman(); // returns یک میلیون و بیست و سه هزار و نهصد و هشتاد و هفت تومان
// showRial option to show Rials ...
const tomanFormat = amount.farsiFormatToman({ showRial: true }); // returns یک میلیون و بیست و سه هزار و نهصد و هشتاد و هفت تومان و شش ریال

special thanks :