format-decimal
v0.1.0
Published
Format thousands and decimals with custom separator: 1.000.000,00
Downloads
575
Maintainers
Readme
Format thousands and decimals with custom separator: 1.000.000,00
Options
You can pass a configuration object as second parameter with the following keys:
- decimal: Symbol to use for decimal point (default:
,
). - precision: Number of decimal digits to show (default:
2
). - thousands: Symbol to use for thousands separator (default:
.
).
Usage
const formatDecimal = require('format-decimal');
console.log(formatDecimal(123456.789)); // 123.456,79
console.log(
formatDecimal(
123456.789,
{
decimal : '.',
precision : 1,
thousands : ','
}
)
); // 123,456.8