Skip to content

Instantly share code, notes, and snippets.

@avoidwork
Last active September 12, 2021 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avoidwork/4698968 to your computer and use it in GitHub Desktop.
Save avoidwork/4698968 to your computer and use it in GitHub Desktop.
filesize.js examples
filesize(500); // "500 B"
filesize(500, {bits: true}); // "4 kbit"
filesize(265318, {base: 2}); // "259.1 KiB"
filesize(265318); // "265.32 kB"
filesize(265318, {round: 0}); // "265 kB"
filesize(265318, {output: "array"}); // [265.32, "kB"]
filesize(265318, {output: "object"}); // {value: 265.32, symbol: "kB", exponent: 1, unit: "kB"}
filesize(1, {symbols: {B: "Б"}}); // "1 Б"
filesize(1024); // "1.02 kB"
filesize(1024, {exponent: 0}); // "1024 B"
filesize(1024, {output: "exponent"}); // 1
filesize(265318, {standard: "jedec"}); // "259.1 KB"
filesize(265318, {base: 2, fullform: true}); // "259.1 kibibytes"
filesize(12, {fullform: true, fullforms: ["байтов"]}); // "12 байтов"
filesize(265318, {separator: ","}); // "265,32 kB"
filesize(265318, {locale: "de"}); // "265,32 kB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment