simple-format-number
v0.1.2
Published
A simple clean way to format numbers with Javascript
Downloads
5,714
Readme
A simple clean way to format numbers with Javascript
Setup
npm install simple-format-number
Usage
var formatNumber = require('simple-format-number');
formatNumber(1000.342); // => 1,000.34
formatNumber(1000.342, { fractionDigits: 3 }): // => 1,000.342
formatNumber(1000.342, { symbols: { decimal: ',', grouping: '.' } }); // => 1.000,34 (italian format)
API
formatNumber(number, options)
where:
number
the number to formatoptions
fractionDigits: number
the number of decimal digits (default2
)useGrouping: boolean
set tofalse
when you want to display a number in a textbox (defaulttrue
)symbols
decimal
the decimal symbol (default.
)grouping
the grouping symbol (default,
)