Download packages/coding-agent/src/utils/sleep.ts from SaylorTwift/pi: direct link, hf CLI and curl.
- Browser
- Download file 402 Bytes
-
https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/utils/sleep.ts
- Command line
-
hf download hf://SaylorTwift/pi/packages/coding-agent/src/utils/sleep.ts
-
curl -L -o sleep.ts https://huggingface.co/SaylorTwift/pi/resolve/main/packages/coding-agent/src/utils/sleep.ts
402 Bytes
| /** | |
| * Sleep helper that respects abort signal. | |
| */ | |
| export function sleep(ms: number, signal?: AbortSignal): Promise<void> { | |
| return new Promise((resolve, reject) => { | |
| if (signal?.aborted) { | |
| reject(new Error("Aborted")); | |
| return; | |
| } | |
| const timeout = setTimeout(resolve, ms); | |
| signal?.addEventListener("abort", () => { | |
| clearTimeout(timeout); | |
| reject(new Error("Aborted")); | |
| }); | |
| }); | |
| } | |