Nuxt Season Finale (#531)

Co-authored-by: Emma Cypress Pointer-Null <emmaffle@modrinth.com>
This commit is contained in:
ProspectorandEmma Cypress Pointer-Null authored and GitHub committed 2022-06-18 21:39:53 -04:00
1 parent 2bda7566b4
commit 405a3eda60
26 files changed
+1690 -952

No files matched your search

+11
View File
@@ -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]
})
}