Travis build: 1500
This commit is contained in:
28
README.md
28
README.md
@ -422,6 +422,7 @@ average(1, 2, 3);
|
||||
* [`RGBToHex`](#rgbtohex)
|
||||
* [`serializeCookie`](#serializecookie)
|
||||
* [`timeTaken`](#timetaken)
|
||||
* [`toCurrency`](#tocurrency)
|
||||
* [`toDecimalMark`](#todecimalmark)
|
||||
* [`toOrdinalSuffix`](#toordinalsuffix)
|
||||
* [`validateNumber`](#validatenumber)
|
||||
@ -7757,6 +7758,33 @@ timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### toCurrency
|
||||
|
||||
Take a number and return specified currency formatting.
|
||||
|
||||
Use `Intl.NumberFormat` to enable country / currency sensitive formatting.
|
||||
|
||||
```js
|
||||
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local
|
||||
toCurrency(123456.789, 'USD', 'en-us'); // €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
|
||||
toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi
|
||||
toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
|
||||
toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### toDecimalMark
|
||||
|
||||
Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark](https://en.wikipedia.org/wiki/Decimal_mark) form. It makes a comma separated string from a number.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -5,13 +5,14 @@ Take a number and return specified currency formatting.
|
||||
Use `Intl.NumberFormat` to enable country / currency sensitive formatting.
|
||||
|
||||
```js
|
||||
const toCurrency = (n, curr, LanguageFormat = undefined) => Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||
const toCurrency = (n, curr, LanguageFormat = undefined) =>
|
||||
Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n);
|
||||
```
|
||||
|
||||
```js
|
||||
toCurrency(123456.789, 'EUR') // €123,456.79 | currency: Euro | currencyLangFormat: Local
|
||||
toCurrency(123456.789, 'USD', 'en-us') // €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
|
||||
toCurrency(123456.789, 'USD', 'fa') // ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi
|
||||
toCurrency(322342436423.2435, 'JPY') // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
|
||||
toCurrency(322342436423.2435, 'JPY', 'fi') // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
|
||||
toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local
|
||||
toCurrency(123456.789, 'USD', 'en-us'); // €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
|
||||
toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ $ | currency: US Dollar | currencyLangFormat: Farsi
|
||||
toCurrency(322342436423.2435, 'JPY'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
|
||||
toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user