add media detail dialog and infinite loading

This commit is contained in:
dswbx
2025-03-27 09:23:14 +01:00
parent 0424c08a9e
commit f6a511d998
17 changed files with 419 additions and 50 deletions

View File

@@ -2,6 +2,7 @@ export * from "./browser";
export * from "./objects";
export * from "./strings";
export * from "./perf";
export * from "./file";
export * from "./reqres";
export * from "./xml";
export type { Prettify, PrettifyRec } from "./types";

View File

@@ -11,3 +11,14 @@ export function ensureInt(value?: string | number | null | undefined): number {
return typeof value === "number" ? value : Number.parseInt(value, 10);
}
export const formatNumber = {
fileSize: (bytes: number, decimals = 2): string => {
if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return Number.parseFloat((bytes / k ** i).toFixed(dm)) + " " + sizes[i];
},
};