gts-x / src /lib /utils.ts
JAMES HAN
Initial commit — GTS Modern subtitle converter
dff41a8
Raw
History Blame Contribute Delete
748 Bytes
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
/**
* Helper function to ensure exhaustive checking in switch statements and conditional logic.
* TypeScript will show a compile error if not all cases are handled.
* @param value - The value that should never be reached
* @throws Error with the unexpected value
*/
export function assertUnreachable(value: never): never {
throw new Error(`Unreachable code reached with value: ${JSON.stringify(value)}`);
}
export function getStringLiteralChecker<T extends readonly string[]>(arr: T) {
return (value:string): value is T[number] => {
return arr.includes(value);
}
}