feat: add annotations, user profiles, watchers, stories, search and more
This commit is contained in:
1 parent
ed469ba8dd
commit
2465bcd184
47 files changed
+5009
-242
No files matched your search
@@ -23,3 +23,21 @@ export function mediaKindLabel(kind: string | null): string | null {
|
||||
}
|
||||
return MEDIA_KIND_LABELS[kind] ?? "Media";
|
||||
}
|
||||
|
||||
const BYTE_UNITS = ["B", "KB", "MB", "GB"];
|
||||
const BYTE_STEP = 1024;
|
||||
|
||||
export function formatBytes(bytes: number | null): string {
|
||||
if (bytes === null || bytes <= 0) {
|
||||
return "";
|
||||
}
|
||||
let value = bytes;
|
||||
let unit = 0;
|
||||
while (value >= BYTE_STEP && unit < BYTE_UNITS.length - 1) {
|
||||
value /= BYTE_STEP;
|
||||
unit++;
|
||||
}
|
||||
const rounded =
|
||||
value >= 10 || unit === 0 ? Math.round(value) : value.toFixed(1);
|
||||
return `${rounded} ${BYTE_UNITS[unit]}`;
|
||||
}
|
||||
Reference in new issue
Block a user