Port to Vue3 and TypeScript

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2025-05-01 13:25:11 +02:00
parent b447417d0f
commit e572d2f545
No known key found for this signature in database
33 changed files with 2297 additions and 5930 deletions

21
src/helpers.ts Normal file
View file

@ -0,0 +1,21 @@
/**
* Converts number of bytes into human format (524288 -> "512.0 KiB")
* @param {number} bytes Byte amount to convert into human readable format
* @returns string
*/
function bytesToHuman(bytes: number): string {
for (const t of [
{ thresh: 1024 * 1024, unit: 'MiB' },
{ thresh: 1024, unit: 'KiB' },
]) {
if (bytes > t.thresh) {
return `${(bytes / t.thresh).toFixed(1)} ${t.unit}`
}
}
return `${bytes} B`
}
export {
bytesToHuman,
}