2.0.0 • Published 5 years ago

prettysize v2.0.0

Weekly downloads
135,637
License
-
Repository
github
Last release
5 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-packionic-gulp-browserify-es2015ionic-gulp-browserify-typescriptionic-gulp-browserify-typescript-babelionic-gulp-browserify-typescript-postTransformmikserlongview-datakoa-better-logmegaraid-infooilspillopenpickeropenui5.runtime.downloaderopizo-apioss-readerobiman-assetsnode-daemonnodebb-plugin-asset-managernode-ipfs-mirrornodejs-infonodefriedperiodicjs.ext.asyncadminperiodicjs.ext.cron_serviceperiodicjs.ext.reactadminperiodicjs.ext.reactapppeercastreact-native-telegram-apk-deployerreact-v2publish-previewprojext-plugin-rollupprettyusesvg-sprite-sachasvg-sprite_lsvg-spritestreambin-cliplayappstorereact-admin-base-bootstrapremark-package-dependenciessizesregistry-staticrf-lsroc-package-webpack-devroc-webtorrent-mountthekdar-uitugger-greetertg-torrent-bottinypng-webptinypngprotinypngpro2tinypng-clitinypng-cli-metadatatinyimgservice.corewebpack-reporter-v2ya-handlebars-bundlerzflixweb-elements-iconsweiler-electrify-react-componentworker-monitorwordsbywhatiswftinifywhaleway2enjoy-clibellcode-tinypngcompressbambu-cli@clusterworks/cdocker@bung87/svg-spritextinypng-cliboss-webboss-cliblinkloader@bpa-solutions/spfx-build-metricsbluntlab-login-motd@infinitebrahmanuniverse/nolb-prettdat-cardcatdevel-info@heroku/worker-monitorchimg@healthstreet/fms-api-clientchillastic@hnordt/sysinfocliflix@digifi-los/reactapp@elsevier/nuxt-performance-audits@ruangnazi/dumpster-dive@faizanhaider/iconsaxelectrode-electrify-react-componentelectrode-electrify-react-component-28electrode-electrify-react-component-29electrode-electrify-react-component-30
2.0.0

5 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

11 years ago

0.0.1

11 years ago