Spaces:
Running
Running
Download src/lib/utils/timeout.ts from huggingchat/chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 239 Bytes
-
https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/utils/timeout.ts
- Command line
-
hf download hf://spaces/huggingchat/chat-ui@refs/pr/511/src/lib/utils/timeout.ts
-
curl -L -o timeout.ts https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/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) | |
| ); | |
| }; | |