From 2468bff5fb423ebcc270685a4cec52120b3a016c Mon Sep 17 00:00:00 2001 From: James Collins Date: Sat, 4 May 2024 18:08:05 +1000 Subject: [PATCH] no decimals for KB and bytes --- public/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index ec836f3..700c235 100644 --- a/public/script.js +++ b/public/script.js @@ -212,9 +212,10 @@ let SM = { } const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; + const fixed = [0, 0, 2, 2, 2]; if (bytes === 0) return '0 Bytes'; const i = Math.floor(Math.log(bytes) / Math.log(1024)); - const size = parseFloat((bytes / Math.pow(1024, i)).toFixed(2)); + const size = parseFloat((bytes / Math.pow(1024, i)).toFixed(fixed[i])); return size + ' ' + sizes[i]; },