numberlabel
Convert a large number to nice formatted string.
Last updated 2 years ago by tiagodanin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install numberlabel 
SYNC missed versions from official npm registry.

Number Label

Node Version Downloads Travis

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.

License

MIT © Tiago Danin

Current Tags

  • 1.0.1                                ...           latest (2 years ago)

2 Versions

  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |