Skip to content

Commit

Permalink
improve the display of sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
p0358 authored Jul 7, 2022
1 parent 4fd1892 commit 3514c43
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ function showFileDetails(f) {


function bytesToSize(bytes) {
var sizes = [' bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 bytes';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return (bytes / Math.pow(1024, i)).toFixed(2) + sizes[i];
let sizes = ['bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) return '0 bytes';
let i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return (bytes / Math.pow(1024, i)).toFixed(i > 0 ? 2 : 0) + ' ' + sizes[i];
}

async function unpackDir(d) {
Expand Down

0 comments on commit 3514c43

Please sign in to comment.