Compare commits

...

1 Commits

Author SHA1 Message Date
Mathias Bynens
cd4e9fd107 Update index.js 2020-12-10 15:58:55 +01:00

View File

@@ -19,11 +19,11 @@ function clamp(v, min, max) {
return v; return v;
} }
const suffix = ['B', 'KB', 'MB']; const suffix = ['B', 'KiB', 'MiB'];
function prettyPrintSize(size) { function prettyPrintSize(size) {
const base = Math.floor(Math.log2(size) / 10); const base = Math.floor(Math.log2(size) / 10);
const index = clamp(base, 0, 2); const index = clamp(base, 0, 2);
return (size / 2 ** (10 * index)).toFixed(2) + suffix[index]; return (size / 2 ** (10 * index)).toFixed(2) + ' ' + suffix[index];
} }
async function decodeFile(file) { async function decodeFile(file) {