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-bot@clusterworks/cdocker@bung87/svg-sprite@bpa-solutions/spfx-build-metrics@ruangnazi/dumpster-diveionic-gulp-browserify-es2015ionic-gulp-browserify-typescriptionic-gulp-browserify-typescript-babelionic-gulp-browserify-typescript-postTransformkoa-better-logstreambin-clitinyimgthekdar-uitinypngprotinypngpro2torrent-mounttinypng-clitinypng-cli-metadatatinypng-webptugger-greeter@apexearth/copy@angularclass/universal-sitegen@digifi-los/reactappya-handlebars-bundlerzflixway2enjoy-clixtinypng-cli@healthstreet/fms-api-client@hnordt/sysinfo@heroku/worker-monitor@elsevier/nuxt-performance-audits@fullstax/svg-sprite@infinitebrahmanuniverse/nolb-prett@next-zero/redux@nodeframe/box-cli@fabiospampinato/watch@faizanhaider/iconsax@nordicsemiconductor/pc-nrfconnect-shared@om-network/uikit@piuccio/json-to-file@packem/bundle-stats-pluginmikseropenui5.runtime.downloadeross-readeropizo-apiopenpickeroilspillobiman-assetspeercastreact-admin-base-bootstraproc-package-webpack-devroc-webregistry-staticremark-package-dependenciesprojext-plugin-rollupreact-native-telegram-apk-deployernode-ipfs-mirrornode-daemonnodejs-infonodefriednodebb-plugin-asset-managerperiodicjs.ext.asyncadminperiodicjs.ext.cron_serviceperiodicjs.ext.reactadminperiodicjs.ext.reactappplayappstoreprettyuserf-lspublish-previewservice.coresizesreact-v2gitboostgood-enoughgrunt-asset-monitorgrunt-contrib-zopfligrunt-svg-spritegrunt-haibugrunt-contrib-compress-staging
2.0.0

7 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago