@pogix3m/short-number
v1.0.1
Published
Convert long number to short number for readability
Downloads
32
Maintainers
Readme
short-number
Convert long number to short number for readability. By default up to Unvigintillion(10^66)
Installation
$ npm install --save @pogix3m/short-number
Usage
var shortNumber = require('@pogix3m/short-number');
shortNumber(1000);
// => 1K
shortNumber(756_159_852);
// => 756.15M
shortNumber(-6248645.13);
// => -6.24M
shortNumber("6248645.13");
// => 6.24M
// provide the suffix
const suffix = [
"Thousand",
"Million",
"Billion",
"Trillion",
"Quadrillion"
];
shortNumber(28728, suffix);
// => 28.72Thousand
shortNumber(756159852, suffix);
// => 756.15Million