Spaces:
Paused
Paused
Download src/lib/utils/debounce.ts from vollsteksolutions/test: direct link, hf CLI and curl.
- Browser
- Download file 415 Bytes
-
https://huggingface.co/spaces/vollsteksolutions/test/resolve/main/src/lib/utils/debounce.ts
- Command line
-
hf download hf://spaces/vollsteksolutions/test/src/lib/utils/debounce.ts
-
curl -L -o debounce.ts https://huggingface.co/spaces/vollsteksolutions/test/resolve/main/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); | |
| }; | |
| } | |