MCPcopy
hub / github.com/xiaolin/react-image-gallery / debounce

Function debounce

src/components/utils/debounce.ts:8–20  ·  view source on GitHub ↗
(
  func: T,
  wait: number
)

Source from the content-addressed store, hash-verified

6 */
7// eslint-disable-next-line @typescript-eslint/no-explicit-any
8export default function debounce<T extends (...args: any[]) => void>(
9 func: T,
10 wait: number
11): (...args: Parameters<T>) => void {
12 let timeoutId: ReturnType<typeof setTimeout> | undefined;
13
14 return function debounced(this: unknown, ...args: Parameters<T>): void {
15 clearTimeout(timeoutId);
16 timeoutId = setTimeout(() => {
17 func.apply(this, args);
18 }, wait);
19 };
20}

Callers 3

ImageGallery.tsxFile · 0.85
utils.test.tsFile · 0.85
useThumbnailsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected