mirror of https://github.com/kern/filepizza
Add speed and peer count.
parent
75e646c4b9
commit
32b6d58a1c
@ -0,0 +1,9 @@
|
||||
// Taken from StackOverflow
|
||||
// http://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
|
||||
export function formatSize(bytes) {
|
||||
if (bytes === 0) return '0 Bytes'
|
||||
const k = 1000
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]
|
||||
}
|
||||
Loading…
Reference in New Issue