/** * Utility function to combine class names * Replaces tailwind-merge and clsx with a simple implementation */ export function cn(...classes: (string | undefined | null | false)[]): string { return classes.filter(Boolean).join(' ') } /** * Format bytes to human readable string */ export function formatBytes(bytes: number): string { if (bytes === 0) return '0 Bytes' const k = 1024 const sizes = ['Bytes', 'KB', 'MB', 'GB'] const i = Math.floor(Math.log(bytes) / Math.log(k)) return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i] } /** * Debounce function */ export function debounce) => unknown>( func: T, wait: number ): (...args: Parameters) => void { let timeout: NodeJS.Timeout | null = null return function executedFunction(...args: Parameters) { const later = () => { timeout = null func(...args) } if (timeout) { clearTimeout(timeout) } timeout = setTimeout(later, wait) } } /** * Sleep utility */ export function sleep(ms: number): Promise { return new Promise(resolve => setTimeout(resolve, ms)) }