Travis build: 1500

This commit is contained in:
30secondsofcode
2018-01-31 17:15:57 +00:00
parent 8f0f3bb44a
commit cf5ab48aba
3 changed files with 43 additions and 7 deletions

View File

@ -422,6 +422,7 @@ average(1, 2, 3);
* [`RGBToHex`](#rgbtohex) * [`RGBToHex`](#rgbtohex)
* [`serializeCookie`](#serializecookie) * [`serializeCookie`](#serializecookie)
* [`timeTaken`](#timetaken) * [`timeTaken`](#timetaken)
* [`toCurrency`](#tocurrency)
* [`toDecimalMark`](#todecimalmark) * [`toDecimalMark`](#todecimalmark)
* [`toOrdinalSuffix`](#toordinalsuffix) * [`toOrdinalSuffix`](#toordinalsuffix)
* [`validateNumber`](#validatenumber) * [`validateNumber`](#validatenumber)
@ -7757,6 +7758,33 @@ timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms
<br>[⬆ Back to top](#table-of-contents) <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 ### 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. 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

View File

@ -5,13 +5,14 @@ Take a number and return specified currency formatting.
Use `Intl.NumberFormat` to enable country / currency sensitive formatting. Use `Intl.NumberFormat` to enable country / currency sensitive formatting.
```js ```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 ```js
toCurrency(123456.789, 'EUR') // €123,456.79 | currency: Euro | currencyLangFormat: Local 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', 'en-us'); // €123,456.79 | currency: US Dollar | currencyLangFormat: English (United States)
toCurrency(123456.789, 'USD', 'fa') // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi 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'); // ¥322,342,436,423 | currency: Japanese Yen | currencyLangFormat: Local
toCurrency(322342436423.2435, 'JPY', 'fi') // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Japanese Yen | currencyLangFormat: Finnish
``` ```