PrettySize
Helper utility to provide pretty printed file sizes (best used for logging or CLI output)
Build Status
Usage
npm install prettysize
const pretty = ; let str = ; //str = "1 kB" str = ; //str = "1 MB" str = ; //str = "117.7 MB"
It supports the following sizes:
- bytes
- kB
- MB
- GB
- TB
- PB
- EB
Arguments
; /* First arg is sizeSecond argument is to remove the space from the outputThird 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 = ; //str = "1MB" str = // pretty(123456789, true, true); //str = "117.7M" str = // pretty(123456789, false, true); //str = "117.7 M" str = // pretty(123456789, false, true, 2); //str = "117.74 M" str = // pretty(123456789, false, true, 3); //str = "117.738 M" str = // pretty(123456789, false, false, false, true); //num = 117.7