MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / debounce

Function debounce

src/utils.ts:465–480  ·  view source on GitHub ↗
(
  fn: T,
  delay: number
)

Source from the content-addressed store, hash-verified

463 * @returns Debounced function
464 */
465export function debounce<T extends (...args: unknown[]) => unknown>(
466 fn: T,
467 delay: number
468): (...args: Parameters<T>) => void {
469 let timeoutId: ReturnType<typeof setTimeout> | null = null;
470
471 return (...args: Parameters<T>) => {
472 if (timeoutId) {
473 clearTimeout(timeoutId);
474 }
475 timeoutId = setTimeout(() => {
476 fn(...args);
477 timeoutId = null;
478 }, delay);
479 };
480}
481
482/**
483 * Throttle a function

Callers 1

WidgetClass · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected