Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz committed Nov 4, 2024
1 parent efd1597 commit 7e74ca3
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,14 @@ qx.Class.define("osparc.utils.Utils", {
if (!+bytes) {
return "0 Bytes";
}

const k = 1000;
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
const dm = decimals < 0 ? 0 : decimals;

const i = Math.floor(Math.log(bytes) / Math.log(k))
return `${isDecimalCollapsed ? parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) : (bytes / Math.pow(k, i)).toFixed(dm)} ${sizes[i]}`
const i = Math.floor(Math.log(bytes) / Math.log(k));
const value = (bytes / Math.pow(k, i)).toFixed(dm);
const metrics = ["Bytes", "kB", "MB", "GB", "TB"];
const metric = i < metrics.length ? metrics[i] : "";
return `${isDecimalCollapsed ? parseFloat(value) : value} ${metric}`
},

bytesToGB: function(bytes) {
Expand Down

0 comments on commit 7e74ca3

Please sign in to comment.