(bytes)
| 1 | import { File } from 'megajs'; |
| 2 | import path from 'path'; |
| 3 | const formatBytes = (bytes) => { |
| 4 | if (bytes === 0) |
| 5 | return '0 Bytes'; |
| 6 | const k = 1024; |
| 7 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; |
| 8 | const i = Math.floor(Math.log(bytes) / Math.log(k)); |
| 9 | return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2)) } ${ sizes[i]}`; |
| 10 | }; |
| 11 | const generateBar = (percentage) => { |
| 12 | const totalBars = 10; |
| 13 | const filledBars = Math.floor((percentage / 100) * totalBars); |