Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (bytes === 0) return '0 Bytes';
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
- return `${parseFloat((bytes / Math.pow(1024, i)).toFixed(2))} ${sizes[i]}`;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement