2.0.0 • Published 6 years ago

prettysize v2.0.0

Weekly downloads
135,637
License
-
Repository
github
Last release
6 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-pack@timsuchanek/copy@tableflip/ipfs-filexp@tenda.digital/webarchiver@vkontakte/svg-sprite@vusion/svg-spriteagetairtaragent-joneschimgchillasticcliflixblinkloaderbluntlab-login-motdbambu-clibellcode-tinypngcompressboss-webboss-clidat-cardcatevildnsestablishment-node-corefile-suckerfile-upload-componentelectrode-electrify-react-componentelectrode-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-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-45electrode-electrify-react-component-26electrode-electrify-react-component-27electrode-electrify-react-component-28electrode-electrify-react-component-29electrode-electrify-react-component-30electrode-electrify-react-component-37fms-api-clientfes-svg-spriteflsabagrunt-contrib-compress-staginggrunt-asset-monitorgrunt-haibugrunt-levin-zipgrunt-contrib-zopfligrunt-svg-spritegulp-browserify-js-inlinefsbxfuse-box-testfuse-torrentfuseboxfusebox-cligitboostguvnorgweiler-electrode-electrify-react-componentgweiler-electrode-webpack-reportergood-enoughdownloadstation-clidevel-infodumpster-divehmshebspack-testionic-gulp-browserify-es2015ionic-gulp-browserify-typescriptionic-gulp-browserify-typescript-babelionic-gulp-browserify-typescript-postTransformprettyuseperiodicjs.ext.asyncadminperiodicjs.ext.cron_serviceperiodicjs.ext.reactadminperiodicjs.ext.reactapppeercastoss-readeropizo-apiopenpickerprojext-plugin-rollupplayappstorepublish-previewreact-admin-base-bootstrap@elsevier/nuxt-performance-audits@healthstreet/fms-api-client@heroku/worker-monitor@digifi-los/reactapp@hnordt/sysinfo
2.0.0

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago

0.0.3

11 years ago

0.0.2

12 years ago

0.0.1

12 years ago