Archived
1
0

Fix human readable byte size when zero

This commit is contained in:
Asher 2019-05-20 15:53:06 -05:00
parent 0462a93f11
commit 4a29cd1664
No known key found for this signature in database
GPG Key ID: 7BB4BA9C783D2BBC

View File

@ -505,9 +505,8 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
*/ */
private humanReadableSize(bytes: number): string { private humanReadableSize(bytes: number): string {
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1); const i = Math.min(Math.floor(bytes && Math.log(bytes) / Math.log(1000)), units.length - 1);
return (bytes / Math.pow(1000, i)).toFixed(2) return (bytes / Math.pow(1000, i)).toFixed(2) + " " + units[i];
+ " " + units[i];
} }
} }