Formats the given bytes into a human-readable file size string
Optionalbytes: number | null
the number of bytes to format (base-1024)
the number of decimal places to keep (defaults to 2)
the formatted size string, e.g. "1.5 KB" or "2.3 MB", or undefined if bytes is absent
formatBytes(0); // "0 B"
formatBytes(512); // "512 B"
formatBytes(1536); // "1.5 KB"
formatBytes(1048576); // "1 MB"
formatBytes(1610612736); // "1.5 GB"
formatBytes(1649267441664); // "1.5 TB"
formatBytes(-1); // "0 B"
formatBytes(Infinity); // "0 B"
formatBytes(); // undefined
formatBytes(undefined); // undefined
formatBytes(null); // undefined
Utilities for file
Author
David Hsing