Spaces:
Runtime error
Runtime error
Liam Dyer
Aaditya Sahay
Aaditya Sahay
Web Search: Playwright, spatial parsing, markdown (#1094)
2c00ea8 unverified Download src/lib/utils/timeout.ts from evijit/pluralchat: direct link, hf CLI and curl.
- Browser
- Download file 312 Bytes
-
https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/utils/timeout.ts
- Command line
-
hf download hf://spaces/evijit/pluralchat@refs/pr/1/src/lib/utils/timeout.ts
-
curl -L -o timeout.ts https://huggingface.co/spaces/evijit/pluralchat/resolve/refs%2Fpr%2F1/src/lib/utils/timeout.ts
312 Bytes
| export const timeout = <T>(prom: Promise<T>, time: number): Promise<T> => { | |
| let timer: NodeJS.Timeout; | |
| return Promise.race([ | |
| prom, | |
| new Promise<T>((_, reject) => { | |
| timer = setTimeout(() => reject(new Error(`Timeout after ${time / 1000} seconds`)), time); | |
| }), | |
| ]).finally(() => clearTimeout(timer)); | |
| }; | |