Skip to content

Instantly share code, notes, and snippets.

@avoidwork
Created March 24, 2012 01:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avoidwork/2176936 to your computer and use it in GitHub Desktop.
Save avoidwork/2176936 to your computer and use it in GitHub Desktop.
filesize.js
filesize(500); // "3.91Kb"
filesize(500, true); // "3.9k"
filesize(1500); // "1.46KB"
filesize("1500000000"); // "1.40GB"
filesize("1500000000", 0); // "1GB"
filesize(1212312421412412); // "1.08PB"
filesize(1212312421412412, true); // "1.1P" - shorthand output, similar to *nix "ls -lh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment