0.0.3 • Published 1 year ago

kmformatter v0.0.3

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
1 year ago

kformatter

Convert numbers to k,m... made easy

Solution to express numbers in k,M,G,T,P,E e.g 1234 to 1.2k, 1243215 to 1.2M

Installation

Using npm:

$ npm i kmformatter

Quick Start

Import the libary and use the format nFormatter(number, decimal)

// load the library
import { formatter } from 'kmformatter';

console.log(formatter(1234, 1));
console.log(formatter(1234, 2));

console.log(formatter(3423567, 1));
console.log(formatter(3423567, 3));

output

$ 1.2k
$ 1.23k
$ 3.4M
$ 3.423M

Special thanks to @Salman A. He wrote the entire solution, I just modified and released it as an npm package for easier usage.

This is the original reddit comment I took the code from.

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago