Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nice-number

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nice-number

Compact formatting of numbers

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
105
increased by144.19%
Maintainers
1
Weekly downloads
 
Created
Source

nice-number

Compact formatting of numbers

For many applications we're only interested in the first few digits of a number. Comparing two similar numbers, if their first three digits are the same and they have the same number of digits, they're close enough to be the same for many purposes. And they take up a lot less screen space. So nice-number gives you a nice representation of the number which is useful for these purposes. Values with an absolute value between 10 and 1,000 are presented as integers; with an absolute value between 1,000 and 1,000,000 as an integer 'K', etc. If they're too large or too small, exponential notation is used.

  • returns 'null' for null
  • returns 'null' for undefined
  • uses exponential notation for values < 0.001
  • uses 0.xxx notation for values < 1
  • uses x.x notation for values < 10
  • uses integer notation for values < 1,000
  • uses K notation for values < 1,000,000
  • uses M notation for values < 1,000,000,000
  • uses G notation for values < 1,000,000,000,000
  • uses exponential notation for values >= 1,000,000,000,000

Keywords

FAQs

Package last updated on 27 Feb 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc