prettysize

WebJar for prettysize

License

License

BSD
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

prettysize
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

prettysize
WebJar for prettysize
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/davglass/prettysize

Download prettysize

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/prettysize/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>prettysize</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/prettysize/
implementation 'org.webjars.npm:prettysize:0.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/prettysize/
implementation ("org.webjars.npm:prettysize:0.0.3")
'org.webjars.npm:prettysize:jar:0.0.3'
<dependency org="org.webjars.npm" name="prettysize" rev="0.0.3">
  <artifact name="prettysize" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='prettysize', version='0.0.3')
)
libraryDependencies += "org.webjars.npm" % "prettysize" % "0.0.3"
[org.webjars.npm/prettysize "0.0.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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

Versions

Version
0.0.3