npm.io
1.1.8 • Published 4 years ago

humanify-numbers

Licence
MIT
Version
1.1.8
Deps
0
Size
5 kB
Vulns
0
Weekly
0

humanify-numbers License: MIT npm version Run example

Stringify numbers for humans, aka Humanify the numbers.

E.g. 1234 ➜ "1.2K"

Install

npm install -s humanify-numbers

TypeScript Usage

Simple TypeScript code:

import { Numbers } from 'humanify-numbers'

console.log("1234567890 ➜", Numbers.stringify(1234567890))
// output: 1.2B

console.log("1234567890 ➜", Numbers.stringify(1234567890, 
                            { style: 'space' })) 
// output: 1.1GiB

console.log("1234567890 ➜", (1234567890).toLocaleString())
// compare with toLocalString(): 1,234,567,890

JavaScript Usage

Same code in simple JavaScript:

const { Numbers } = require("humanify-numbers");

console.log("1234 ➜", Numbers.stringify(1234)); 
// output: 1234 ➜ 1.2K

Read more.

Keywords