2.0.0 • Published 7 years ago

prettysize v2.0.0

Weekly downloads
135,637
License
-
Repository
github
Last release
7 years ago

PrettySize

Helper utility to provide pretty printed file sizes (best used for logging or CLI output)

Build Status

Build Status codecov

Usage

npm install prettysize
const pretty = require('prettysize');

let str = pretty(1024);
  //str = "1 kB"

    str = pretty(1024 * 1024);
  //str = "1 MB"

    str = pretty(123456789);
  //str = "117.7 MB"

It supports the following sizes:

  • bytes
  • kB
  • MB
  • GB
  • TB
  • PB
  • EB

Arguments

pretty(123456, true, true, 2);

/*

First arg is size
Second argument is to remove the space from the output
Third argument is to use a single character for the size.
Forth argument is the number of decimal places to return, default is 1.
Fith argument is to return a converted number without the size string.
*/


let str = pretty(1024 * 1024, true);
  //str = "1MB"

    str = pretty(123456789, {nospace: true}) // pretty(123456789, true, true);
  //str = "117.7M"

    str = pretty(123456789, {one: true}) // pretty(123456789, false, true);
  //str = "117.7 M"

    str = pretty(123456789, {one: true, places: 2}) // pretty(123456789, false, true, 2);
  //str = "117.74 M"

   str = pretty(123456789, {one: true, places: 3}) // pretty(123456789, false, true, 3);
 //str = "117.738 M"

   str = pretty(123456789, {numOnly: true}) // pretty(123456789, false, false, false, true);
 //num = 117.7
nodewebx-cdnwedeploy-console@thebestco/pubsub@next-zero/frameworktotal-traffic-traderavrorajs@twbs/svg-spritehealth-app-base@everything-registry/sub-chunk-2471test-ui-packwhatisweb-elements-iconswebpack-reporter-v2weiler-electrify-react-componentwordsbyworker-monitorwftinifywhalesvg-sprite-sachasvg-spritesvg-sprite_ltg-torrent-botionic-gulp-browserify-es2015ionic-gulp-browserify-typescriptionic-gulp-browserify-typescript-babelionic-gulp-browserify-typescript-postTransformkoa-better-loggulp-browserify-js-inlinehmshebspack-testgweiler-electrode-electrify-react-componentgweiler-electrode-webpack-reporterguvnorlongview-datamegaraid-info@timsuchanek/copy@vkontakte/svg-sprite@vusion/svg-sprite@tenda.digital/webarchiveragent-jonesagetairtarfsbxfuse-torrentfuseboxfuse-box-testfusebox-clidumpster-diveelectrode-electrify-react-componentelectrode-electrify-react-component-26electrode-electrify-react-component-27electrode-electrify-react-component-28electrode-electrify-react-component-29electrode-electrify-react-component-30electrode-electrify-react-component-31electrode-electrify-react-component-32electrode-electrify-react-component-33electrode-electrify-react-component-34electrode-electrify-react-component-35electrode-electrify-react-component-36electrode-electrify-react-component-37electrode-electrify-react-component-38electrode-electrify-react-component-39electrode-electrify-react-component-40electrode-electrify-react-component-41electrode-electrify-react-component-42electrode-electrify-react-component-43electrode-electrify-react-component-44electrode-electrify-react-component-45evildnsestablishment-node-corefes-svg-spritefile-upload-componentfile-suckerflsabafms-api-clientchillasticchimgcliflixdat-cardcatblinkloaderbellcode-tinypngcompressbambu-clibluntlab-login-motdboss-webboss-clidevel-infodownloadstation-clistreambin-clitinyimgthekdar-uitinypngprotinypngpro2torrent-mounttinypng-clitinypng-cli-metadatatinypng-webptugger-greeterya-handlebars-bundlerzflix
2.0.0

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.1.0

9 years ago

0.0.3

12 years ago

0.0.2

13 years ago

0.0.1

13 years ago