2024-09-05 15:50:11 -04:00
|
|
|
module.exports = function (bytes) {
|
2024-09-12 00:26:36 -04:00
|
|
|
if (bytes >= 1125899906842624) { // Petabytes
|
2024-09-05 15:50:11 -04:00
|
|
|
return `${Math.round(bytes / 1125899906842624 * 100) / 100} PB`
|
2024-09-12 00:26:36 -04:00
|
|
|
} else if (bytes >= 1099511627776) { // Terabytes
|
2024-09-05 15:50:11 -04:00
|
|
|
return `${Math.round(bytes / 1099511627776 * 100) / 100} TB`
|
2024-09-12 00:26:36 -04:00
|
|
|
} else if (bytes >= 1073741824) { // Gigabytes
|
2024-09-05 15:50:11 -04:00
|
|
|
return `${Math.round(bytes / 1073741824 * 100) / 100} GB`
|
2024-09-12 00:26:36 -04:00
|
|
|
} else if (bytes >= 1048576) { // Megabytes
|
2024-09-05 15:50:11 -04:00
|
|
|
return `${Math.round(bytes / 1048576 * 100) / 100} MB`
|
2024-09-12 00:26:36 -04:00
|
|
|
} else if (bytes >= 1024) { // Kilobytes
|
2024-09-05 15:50:11 -04:00
|
|
|
return `${Math.round(bytes / 1024 * 100) / 100} KB`
|
|
|
|
} else { // Bytes
|
|
|
|
return `${bytes} B`
|
|
|
|
}
|
|
|
|
}
|