num-to-txt
v1.0.1
Published
enables you to create formalspoken format for numbers that represent an amount
Maintainers
Readme
number to text converter
This NodeJs library enables you to create spoken format for numbers that represent an amount in countries currency .
install
using npm :
$ npm i num-to-txt --saveUsage
const Amount = require("@farad845/number-to-text");
const amount = new Amount(10239876);
// defualt language set to "EN"
// you can change it by passing as second parameter like this :
const amountWithCountry = new Amount(10239876, "Fa"); Grouping Digits
To group digits by three, use
// The settings are optional,
// you can pass it as object
const withDigitGrouping = amount.digitGrouped(); // returns 10,239,876options
for Ex :
// language = "FA"
const withDigitGrouping = amount.digitGrouped({ comma : "،" }); // returns ۱۰،۲۳۹،۸۷۶
const withDigitGrouping = amount.digitGrouped({ numbersInEnglishCharcters : true }); // returns 10,239,876or
const withDigitGrouping = amount.digitGrouped({ groupDigitBy: 2 }); // returns 10,23,98,76Convert To Text
To display spoken format, use
/*
** language = "FA"
** The settings are optional,
** you can pass it as object
*/
const textFormat = amount.toText(); // returns ده میلیون و دویست و سی و نه هزار و هشتصد و هفتاد و ششoptions
To display spoken format in Rials (IRR), use
const tomanFormat = amount.farsiFormatToman({ badge: "ریال" }); // returns ده میلیون و دویست و سی و نه هزار و هشتصد و هفتاد و شش ریالcontribute
add your language
1 - create a folder named YOUR-LANGUGE inside the numberToString folder
2 - look at the persian folder, inside the numberToString folder
3 - fill your folder like that
4 - edit and add your files to index.js inside the numberToString folder
5 - create a js file named YOUR-LANGUGE inside the functions/util folder
6 - edit and add your files to index.js inside the functions/util folder
7 - pull request
