bytesToString = function (bytes) {
let format = d3.format(".0f");
if (bytes < 1024) {
return format(bytes) + "B";
} else if (bytes < 1024 * 1024) {
return format(bytes / 1024) + "kB";
} else if (bytes < 1024 * 1024 * 1024) {
return format(bytes / 1024 / 1024) + "MB";
} else if (bytes < 1024 * 1024 * 1024 * 1024) {
return format(bytes / 1024 / 1024 / 1024) + "GB";
} else if (bytes < 1024 * 1024 * 1024 * 1024 * 1024) {
return format(bytes / 1024 / 1024 / 1024 / 1024) + "TB";
} else {
return (
d3.format(",")(format(bytes / 1024 / 1024 / 1024 / 1024 / 1024)) + "PB"
);
}
}