Add owner-only attachment summaries and a compact member management table. Keep personal attachment statistics unchanged and exclude Trash from usage totals. Refs #553
13 lines
410 B
TypeScript
13 lines
410 B
TypeScript
export const formatBytes = (bytes: number) => {
|
|
if (!Number.isFinite(bytes) || bytes <= 0) {
|
|
return "0 B";
|
|
}
|
|
|
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
|
|
const value = bytes / 1024 ** exponent;
|
|
|
|
return `${exponent === 0 ? value.toFixed(0) : value.toFixed(value >= 10 ? 1 : 2)} ${units[exponent]}`;
|
|
};
|
|
|