Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
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

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
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

format

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