num-format ·
Number pretty printer for currency, percents, and adding thousands separators.
FormatCurrency
Parameters
number
: Number - Value to convertroundToInteger
: Boolean - Defaults to true
(Optional)locale
: String - Defaults to 'en-US'
(Optional)currency
: String - Defaults to 'USD'
(Optional)
Examples
>> FormatCurrency(123456, false);
>> FormatCurrency(123456.78, false);
>> FormatCurrency(9876.54);
>> FormatCurrency(123456.78, true, 'en-GB', 'GBP');
FormatNumber
Parameters
number
: Number - Value to convertprecision
: Number - Defaults to 2
(Optional)locale
: String - Defaults to 'en-US'
(Optional)
Examples
>> FormatNumber(1000);
>> FormatNumber(1234567.89, 1);
>> FormatNumber(22333.44, 0);
FormatPercent
Parameters
number
: Number - Value to convertprecision
: Number - Defaults to 2
(Optional)locale
: String - Defaults to 'en-US' (Optional)
Examples
>> FormatPercent(0.8522);
>> FormatPercent(0.135);
>> FormatPercent(0.7337, 1);
>> FormatPercent(0.5567, 0);
>> FormatPercent(0.3312, 0);
Locale Support:
In the current version of num-format it should be assumed that only en-US
formatting is supported as Node 8.x has limited locale support.
num-format uses Semantic Versioning. | Copyright © 2018 Chris Kilpatrick. Released under MIT License.