1.0.1 • Published 6 years ago
@nlib/human-readable v1.0.1
@nlib/human-readable
Converts an integer to a human readable format.
Install
npm install @nlib/human-readable
Usage
const console = require('console');
const humanReadable = require('@nlib/human-readable');
console.log(humanReadable(1000));
// 1K
console.log(humanReadable(1000000));
// 1M
Javascript API
humanReadable(size: Number, options: ?Object]) → String
- size: An integer to be converted.
- options: configures behavior.
- round: Function. The default value is Math.round.
- base: Number. The default value is 1000. humanReadable(2048, {base: 1024}) → '2.0K'.
- digits: Number. The default value is 1. humanReadable(2000, {digits: 3}) → '2.000K'.
- prefix: array-like. The default value is ' KMGTPEZY'. humanReadable(2000, {prefix: , 'Kilo'}) → '2.0Kilo'.
- negativePrefix: array-like. The default value is ' mμnpfazy'. humanReadable(0.02, {negativePrefix: , 'milli'}) → '20milli'.
LICENSE
MIT