# num-to-txt

> enables you to create formalspoken format for numbers that represent an amount

Latest version **1.0.1** (published 2019-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install num-to-txt
pnpm add num-to-txt
yarn add num-to-txt
bun add num-to-txt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-08-06 |
| First published | 2019-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | farzadshami |
| Maintainers | farzad845 |
| Keywords | node.js, persian, persian Number, Number to String |

## Links

- npm: https://www.npmjs.com/package/num-to-txt
- Repository: https://github.com/FaRzad-845/numberToText
- Homepage: https://github.com/FaRzad-845/numberToText#readme
- Issues: https://github.com/FaRzad-845/iramount/issues
- npm.io page: https://npm.io/package/num-to-txt

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-08-06
- 1.0.0 — 2019-08-06

## 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 :

```javascript
$ npm i num-to-txt --save
```
## Usage

```javascript
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
```javascript
// The settings are optional, 
// you can pass it as object
const withDigitGrouping = amount.digitGrouped(); // returns 10,239,876
```
#### options  
<ul>
  <li>
   amount 
  </li>
  <li>
   groupDigitBy || default value set to 3, means divide number three digit, three digit
  </li>
  <li>
   numbersInEnglishCharcters || defult value set to false, it means your number is shown as entered Country if you want to show in english charchers set it to true
  </li>
  <li>
   decimalCount || defult value set to 0, it means if yor number is float it rounds up your number and show that without any decimals, if you want to see number with decimal, set the decimal count
  </li>
  <li>
   comma || defult value set to ",", it means you get numbers like this 12,555
  </li>
</ul>

for Ex :

```javascript
// language = "FA"
const withDigitGrouping = amount.digitGrouped({ comma : "،" }); // returns ۱۰،۲۳۹،۸۷۶
const withDigitGrouping = amount.digitGrouped({ numbersInEnglishCharcters : true }); // returns 10,239,876
```
or 
```javascript
const withDigitGrouping = amount.digitGrouped({ groupDigitBy: 2 }); // returns 10,23,98,76
```

### Convert To Text

To display spoken format, use
```javascript
/*
** language = "FA"
** The settings are optional, 
** you can pass it as object
*/
const textFormat = amount.toText(); // returns ده میلیون و دویست و سی و نه هزار و هشتصد و هفتاد و شش
```

#### options 

<ul>
  <li>
   withDecimals || default value is false, if you want to convert float part to text put it to true 
  </li>
  <li>
   badge 
  </li>
  <li>
   secondBadge || it works if you set withDecimals to true
  </li>
  <li>
   seprator || it works if you set withDecimals to true
  </li>
</ul>

To display spoken format in Rials (IRR), use
```javascript
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

---
_Source: https://npm.io/package/num-to-txt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
