JSPM

prettybandwidth

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q27280F
  • License MIT

Convert bandwidth values to prettier format. (123456789 -> 117.7 Mb/s)

Package Exports

  • prettybandwidth

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prettybandwidth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

PrettyBandwidth NPM version NPM monthly downloads Linux Build Status

Convert bandwidth values to prettier format (123456789 -> 117.7 Mb/s)

Supported bandwidth units:
* b/s
* kb/s
* Mb/s
* Gb/s
* Tb/s
* Pb/s
* Eb/s

Install

Install with npm:

$ npm install --save prettybandwidth

Usage

const prettyb = require('prettybandwidth');

let x = prettyb(1024);
  //x = "1 kb/s"

    x = prettyb(1024 * 1024);
  //x = "1 Mb/s"

    x = prettyb(123456789);
  //x = "117.7 Mb/s"

Options

prettyb(123456, true, true, 2);

/*
First arg is bandwidth in bytes (integer)
Second argument is to remove the space from the output (boolean)
Third argument is to use a single character for the bandwidth (boolean)
Forth argument is the number of decimal places to return, default is 1 (integer). 
*/


let x = prettyb(123456789, {short: true}) // prettyb(123456789, true);
  //x = "117.7Mb/s"

    x = prettyb(123456789, {unitOnly: true}) // prettyb(123456789, false, true);
  //x = "117.7 M"

    x = prettyb(123456789, {unitOnly: true, precision: 2}) // prettyb(123456789, false, true, 2);
  //x = "117.74 M"

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

License

Copyright © 2018, acronpl. Released under the MIT License.