diff --git a/src/functions/dataConversion.ts b/src/functions/dataConversion.ts index e38337d..f72a611 100644 --- a/src/functions/dataConversion.ts +++ b/src/functions/dataConversion.ts @@ -1,5 +1,8 @@ -export default function dataConversion(bytes: number) { +export default function dataConversion(bytes) { const i = Math.floor(Math.log(bytes) / Math.log(1024)); const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + if (bytes === 0) { + return '0 KB'; + } return `${(bytes / 1024 ** i).toFixed(2)} ${sizes[i]}`; }