svelte 5 mit npm

This commit is contained in:
titver968
2025-04-11 11:31:10 +02:00
parent 104e86136b
commit 38f8b7c1a9
82 changed files with 10708 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
const KILO = 1024;
const MEGA = KILO * KILO;
const GIGA = MEGA * KILO;
/**
* Shortens the size in bytes
* @param {number} size
* @returns{string}
*/
export default function shortenFileSize(size) {
const giga = Math.floor(size / GIGA);
let remainder = size % GIGA;
const mega = Math.floor(remainder / MEGA);
remainder %= MEGA;
const kilo = Math.floor(remainder / KILO);
remainder %= KILO;
if (giga > 0) return `${giga} GB`;
if (mega > 0) return `${mega} MB`;
if (kilo > 0) return `${kilo} kB`;
return `${remainder} B`;
}