Socket
Socket
Sign inDemoInstall

nice-number

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nice-number

Compact formatting of numbers


Version published
Weekly downloads
179
increased by65.74%
Maintainers
1
Install size
5.90 kB
Created
Weekly downloads
 

Readme

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

Last updated on 27 Feb 2017

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