From cd20f098fa8ddb088c699b410b39c7850c219098 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Thu, 2 Sep 2021 18:36:56 +0200 Subject: [PATCH] fixed 0 size display --- src/functions/sizeToReadable.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/functions/sizeToReadable.ts b/src/functions/sizeToReadable.ts index ecd4ec3..90a6797 100644 --- a/src/functions/sizeToReadable.ts +++ b/src/functions/sizeToReadable.ts @@ -1,4 +1,6 @@ function sizeToReadable(size: number): string { + if (size == 0) + return "0 B" const i = Math.floor(Math.log(size) / Math.log(1024)) const num = (size / Math.pow(1024, i)) return (num.toFixed(1).endsWith("0")?num.toFixed(0):num.toFixed(1)) + " " + ["B", "kB", "MB", "GB", "TB"][i]