Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@based/pretty-number
Advanced tools
Readme
Small package to nicely format a to a specific format, using a human-readable style.
This package transform a numerical value to a specific format, including converting bytes to to kilobytes, and so on.
$ npm i @based/pretty-number
import { prettyNumber } from '@based/pretty-number'
let number = 500000
console.log(prettyNumber(number,'number-short')) // => prints '50k'
console.log(prettyNumber(number,'number-human')) // => prints '500000.00'
console.log(prettyNumber(number,'number-bytes')) // => prints '48.83 kb'
console.log(prettyNumber(number,'number-euro')) // => prints '€50k'
console.log(prettyNumber(number,'number-dollar')) // => prints '$50k'
console.log(prettyNumber(number,'number-pound')) // => prints '£50k'
number = 0.05
console.log(prettyNumber(number,'number-ratio')) // => prints '5%'
The available formats are listed below:
number-short
This will change the thousands to 'k', and the millions to 'm', adding a decimal point afterwards.
number-human
This will add a decimal point.
number-bytes
This will convert the input from bytes to their binary multiples, where 1 kb = 1024 bytes, 1 mb = 1048576 bytes, and so on.
number-euro
Will do the same as number-short
, but prefixes a '€' sign.
number-dollar
Will do the same as number-short
, but prefixes a '$' sign.
number-pound
Will do the same as number-short
, but prefixes a '£' sign.
number-ratio
Will show a percentage. Note that 1 equals 100%.
FAQs
Small package to nicely format a to a specific format, using a human-readable style.
The npm package @based/pretty-number receives a total of 86 weekly downloads. As such, @based/pretty-number popularity was classified as not popular.
We found that @based/pretty-number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.