Published
Edited
Jun 2, 2022
2 stars
Also listed in…
Tips and Utilities
Insert cell
Insert cell
Insert cell
Insert cell
fs = import('https://unpkg.com/filesize@9.0.1/lib/filesize.esm.js?module')
Insert cell
filesize = fs.default
Insert cell
{
yield [
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"
]
}
Insert cell
Insert cell
{
yield `file size of ${size} is ${filesize(size)}`
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more