Socket
Socket
Sign inDemoInstall

simple-format-number

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    simple-format-number

A simple clean way to format numbers with Javascript


Version published
Weekly downloads
754
decreased by-6.1%
Maintainers
1
Install size
4.78 kB
Created
Weekly downloads
 

Changelog

Source

v0.1.2

  • Internal
    • removed lodash in favor of simple option defaults (thanks @wesleytodd)

Readme

Source

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

Keywords

FAQs

Last updated on 03 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc