Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 19705x 19705x 19705x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 10x 10x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x | import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
/**
* Utility function to merge Tailwind CSS classes
*
* Combines clsx for conditional classes and tailwind-merge for deduplication.
* This ensures Tailwind classes are properly merged without conflicts.
*
* @param inputs - Class names to merge
* @returns Merged class string
*
* @example
* ```ts
* cn('px-2 py-1', 'px-4') // Returns: 'py-1 px-4' (px-4 overrides px-2)
* cn('text-red', condition && 'text-blue') // Conditional classes
* ```
*/
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
* Truncate text to specified length
*
* @param text - Text to truncate
* @param length - Maximum length
* @param suffix - Suffix to add (default: '...')
* @returns Truncated text
*
* @example
* ```ts
* truncate('Hello World', 5) // Returns: "Hello..."
* ```
*/
export function truncate(text: string, length: number, suffix: string = '...'): string {
if (text.length <= length) return text;
return text.slice(0, length) + suffix;
}
/**
* Sleep/delay utility
*
* @param ms - Milliseconds to sleep
* @returns Promise that resolves after delay
*
* @example
* ```ts
* await sleep(1000); // Wait 1 second
* ```
*/
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
|