New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

human-number

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

human-number

Convert number to a human readable string: `13500` → `13.5K`

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
616
decreased by-87.28%
Maintainers
1
Weekly downloads
 
Created
Source

human-number

Last version Coverage Status NPM Status

Convert number to a human readable string (1350013.5K) based on SI prefixes.

Install

$ npm install human-number --save

Usage

const humanNumber = require('human-number')
humanNumber(100) // 100
humanNumber(1_000) // 1K
humanNumber(1_500) // 1.5K
humanNumber(10_000) // 10K
humanNumber(10_500) // 10.5K
humanNumber(100_000) // 100K
humanNumber(100_500) // 100.5K
humanNumber(1_000_000) // 1M
humanNumber(1_500_000) // 1.5M
humanNumber(1_000_000_000) // 1B
humanNumber(1_500_000_000) // 1.5B
humanNumber(1_000_000_000_000) // 1T
humanNumber(1_500_000_000_000) // 1.5T

You can pass a mapper as second parameter:

const humanNumber = require('human-number')
humanNumber(100, n => Number.parseFloat(n).toFixed(1)) // '100.0'

License

human-number © Kiko Beats, released under the MIT License.
Authored and maintained by Kiko Beats with help from contributors.

kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats

Keywords

FAQs

Package last updated on 23 Oct 2023

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