You've already forked AstralRinth
forked from didirus/AstralRinth
Nuxt Season Finale (#531)
Co-authored-by: Emma Cypress Pointer-Null <emmaffle@modrinth.com>
This commit is contained in:
@@ -98,4 +98,15 @@ export default ({ store }, inject) => {
|
||||
|
||||
return output.join(', ')
|
||||
})
|
||||
inject('formatBytes', (bytes, decimals = 2) => {
|
||||
if (bytes === 0) return '0 Bytes'
|
||||
|
||||
const k = 1024
|
||||
const dm = decimals < 0 ? 0 : decimals
|
||||
const sizes = ['Bytes', 'KiB', 'MiB', 'GiB']
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user