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

Function debounce

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

Source from the content-addressed store, hash-verified

786 * @returns Debounced function
787 */
788export function debounce<T extends (...args: unknown[]) => unknown>(
789 fn: T,
790 delay: number
791): (...args: Parameters<T>) => void {
792 let timeoutId: ReturnType<typeof setTimeout> | null = null;
793
794 return (...args: Parameters<T>) => {
795 if (timeoutId) {
796 clearTimeout(timeoutId);
797 }
798 timeoutId = setTimeout(() => {
799 fn(...args);
800 timeoutId = null;
801 }, delay);
802 };
803}
804
805/**
806 * Throttle a function

Callers 1

WidgetClass · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected