This commit is contained in:
padreug 2025-02-15 02:34:19 +01:00
parent 8df44506c0
commit 2bbb9ae938
10 changed files with 47 additions and 9 deletions

View file

@ -4,3 +4,12 @@ import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export async function withTimeout<T>(promise: Promise<T>, timeoutMs: number = 10000): Promise<T> {
return Promise.race([
promise,
new Promise<T>((_, reject) =>
setTimeout(() => reject(new Error('Operation timed out')), timeoutMs)
)
])
}