format-decimal

0.1.0 • Public • Published

format-decimal stable

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

npm install format-decimal

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

Package Sidebar

Install

npm i format-decimal

Weekly Downloads

37

Version

0.1.0

License

MIT

Last publish

Collaborators

  • joaquinfq