Spaces:
Running
Running
Download src/lib/utils/debounce.ts from huggingchat/chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 415 Bytes
-
https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/utils/debounce.ts
- Command line
-
hf download hf://spaces/huggingchat/chat-ui@refs/pr/511/src/lib/utils/debounce.ts
-
curl -L -o debounce.ts https://huggingface.co/spaces/huggingchat/chat-ui/resolve/refs%2Fpr%2F511/src/lib/utils/debounce.ts
415 Bytes
| /** | |
| * A debounce function that works in both browser and Nodejs. | |
| * For pure Nodejs work, prefer the `Debouncer` class. | |
| */ | |
| export function debounce<T extends unknown[]>( | |
| callback: (...rest: T) => unknown, | |
| limit: number | |
| ): (...rest: T) => void { | |
| let timer: ReturnType<typeof setTimeout>; | |
| return function (...rest) { | |
| clearTimeout(timer); | |
| timer = setTimeout(() => { | |
| callback(...rest); | |
| }, limit); | |
| }; | |
| } | |