(bytes: number)
| 42 | |
| 43 | // Pure Utility Functions |
| 44 | export function formatSize(bytes: number): string { |
| 45 | const units = ['B', 'KB', 'MB', 'GB', 'TB']; |
| 46 | if (bytes === 0) return '0 B'; |
| 47 | |
| 48 | const i = Math.floor(Math.log(bytes) / Math.log(1024)); |
| 49 | |
| 50 | if (i < 0 || i === 0) return `${bytes} ${units[0]}`; |
| 51 | |
| 52 | const unitIndex = Math.min(i, units.length - 1); |
| 53 | return `${(bytes / Math.pow(1024, unitIndex)).toFixed(2)} ${units[unitIndex]}`; |
| 54 | } |
| 55 | |
| 56 | export function normalizeLineEndings(text: string): string { |
| 57 | return text.replace(/\r\n/g, '\n'); |
no outgoing calls
no test coverage detected