* Format bytes to human readable
(bytes)
| 35 | * Format bytes to human readable |
| 36 | */ |
| 37 | function formatBytes (bytes) { |
| 38 | if (bytes === 0) return '0 B' |
| 39 | const k = 1024 |
| 40 | const sizes = ['B', 'KB', 'MB', 'GB'] |
| 41 | const i = Math.floor(Math.log(bytes) / Math.log(k)) |
| 42 | return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i] |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Make an HTTP GET request and download to a file with progress |
no outgoing calls
no test coverage detected