simple-format-number

0.1.2 • Public • Published

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 format
  • options
    • fractionDigits: number the number of decimal digits (default 2)
    • useGrouping: boolean set to false when you want to display a number in a textbox (default true)
    • symbols
      • decimal the decimal symbol (default .)
      • grouping the grouping symbol (default ,)

Readme

Keywords

Package Sidebar

Install

npm i simple-format-number

Weekly Downloads

649

Version

0.1.2

License

MIT

Last publish

Collaborators

  • gcanti