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