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 ,)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    776
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    776
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i simple-format-number

Weekly Downloads

776

Version

0.1.2

License

MIT

Last publish

Collaborators

  • gcanti