MCPcopy Index your code
hub / github.com/colbymchenry/codegraph / debounce

Function debounce

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

Source from the content-addressed store, hash-verified

451 * @returns Debounced function
452 */
453export function debounce<T extends (...args: unknown[]) => unknown>(
454 fn: T,
455 delay: number
456): (...args: Parameters<T>) => void {
457 let timeoutId: ReturnType<typeof setTimeout> | null = null;
458
459 return (...args: Parameters<T>) => {
460 if (timeoutId) {
461 clearTimeout(timeoutId);
462 }
463 timeoutId = setTimeout(() => {
464 fn(...args);
465 timeoutId = null;
466 }, delay);
467 };
468}
469
470/**
471 * Throttle a function

Callers

nothing calls this directly

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected