Download src/lib/utils/timeout.ts from WOosts/chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 239 Bytes
-
https://huggingface.co/spaces/WOosts/chat-ui/resolve/main/src/lib/utils/timeout.ts
- Command line
-
hf download hf://spaces/WOosts/chat-ui/src/lib/utils/timeout.ts
-
curl -L -o timeout.ts https://huggingface.co/spaces/WOosts/chat-ui/resolve/main/src/lib/utils/timeout.ts
239 Bytes
| export const timeout = <T>(prom: Promise<T>, time: number): Promise<T> => { | |
| let timer: NodeJS.Timeout; | |
| return Promise.race([prom, new Promise<T>((_r, rej) => (timer = setTimeout(rej, time)))]).finally( | |
| () => clearTimeout(timer) | |
| ); | |
| }; | |