numberlabel
v1.0.1
Published
Convert a large number to nice formatted string.
Downloads
603
Readme
Number Label
Convert a large number to nice formatted string.
Features
- No dependencies
- Easy to Use
- Use the International System of Units (SI)
Installation
Module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
# NPM
npm install numberlabel --save
# Or Using Yarn
yarn add numberlabel
Usage
const label = require('numberlabel')
//Amounts
label.amounts //[{pow, name, symbo, prefix...
//Convert(number, type[prefix, symbol, prefix], {start: 0, toFixed: 2})
label.convert(1567000, 'name') //''1.57 Million'
label.convert(1567000, 'symbol') //'1.27M'
label.convert(1567000, 'prefix') //'1.57 Mega'
label.convert(100, 'prefix', {start: 500}) //'100'
label.convert(100, 'prefix', {start: 500, toFixed: 4}) //'1.0000'
label.convert(100, 'prefix', {start: 500, toFixed: 4}) //'7.0000 Hecto'
label.convert(0.00101) //'1.01 Thousandth'
//getLabel(number, {start: 0, toFixed: 2, type: type[prefix, symbol, prefix]})
label.getLabel(100, {type: 'prefix'}) //{number:'1.00', pow: 2,...
Tests
To run the test suite, first install the dependencies, then run test
:
# NPM
npm test
# Or Using Yarn
yarn test
Dependencies
None
Related
- bytelabel: convert byte lengths into a nice formatted string
Contributors
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. List of all contributors.