(n)
| 2994 | } |
| 2995 | |
| 2996 | function formatBytes(n) { |
| 2997 | const num = Number(n || 0); |
| 2998 | if (!Number.isFinite(num) || num <= 0) return '0 B'; |
| 2999 | const units = ['B', 'KB', 'MB', 'GB', 'TB']; |
| 3000 | let v = num; |
| 3001 | let i = 0; |
| 3002 | while (v >= 1024 && i < units.length - 1) { v /= 1024; i++; } |
| 3003 | const dp = (i === 0) ? 0 : (i === 1 ? 0 : 1); |
| 3004 | return `${v.toFixed(dp)} ${units[i]}`; |
| 3005 | } |
| 3006 | |
| 3007 | function formatDuration(ms) { |
| 3008 | const total = Math.max(0, Math.floor(Number(ms || 0) / 1000)); |
no outgoing calls
no test coverage detected