mirror of
https://github.com/strapi/strapi.git
synced 2025-08-16 20:57:34 +00:00
14 lines
281 B
JavaScript
14 lines
281 B
JavaScript
import byteSize from 'byte-size';
|
|
|
|
function formatBytes(receivedBytes, decimals = 0) {
|
|
const { value, unit } = byteSize(receivedBytes * 1000, { precision: decimals });
|
|
|
|
if (!unit) {
|
|
return '0B';
|
|
}
|
|
|
|
return `${value}${unit.toUpperCase()}`;
|
|
}
|
|
|
|
export default formatBytes;
|