feat(lib): shelf sort/section pure helpers + formatSize extraction, table tests

This commit is contained in:
2026-09-08 17:29:07 +08:00
parent 03bc537308
commit 913f3286bb
5 changed files with 72 additions and 9 deletions
+8
View File
@@ -0,0 +1,8 @@
export function formatSize(bytes: number): string {
if (bytes <= 0) return "";
const units = ["B", "KB", "MB", "GB"];
let i = 0;
let n = bytes;
for (; n >= 1024 && i < units.length - 1; i++) n /= 1024;
return `${n >= 10 || i === 0 ? Math.round(n) : n.toFixed(1)} ${units[i]}`;
}