filesize.js

Try it!

Show `bit` sizes Unix mode (base 2)

 

Download

Latest version is available from Content Delivery Network

What does it do?

filesize.js is a tiny JavaScript library that creates a Global function named filesize().

It provides an easy way to get a human readable file size String.

How do I use it?

filesize.js can be loaded from npm, as an AMD module, or as a regular script.

filesize() accepts an optional descriptor Object as a second argument, so you can customize the output.

Optional settings

bits (boolean)
Enables bit sizes, default is false

unix (boolean)
Enables unix style human readable output, e.g ls -lh, default is false

base (number)
Number base, default is 10

round (number)
Decimal place, default is 2

spacer (string)
Character between the result and suffix, default is " "

suffixes (object)
Dictionary of SI suffixes to replace for localization, defaults to english if no match is found

Examples

Fork me on GitHub