function bytes(value) { const n = Number(value) || 0; const units = ["B", "KB", "MB", "GB", "TB"]; let size = n; let unit = 0; while (size >= 1024 && unit < units.length - 1) { size /= 1024; unit += 1; } return `${size.toFixed(unit === 0 ? 0 : 1)} ${units[unit]}`; } function percent(value) { return `${Math.max(0, Math.min(100, Math.round(Number(value) || 0)))}%`; } module.exports = { bytes, percent };