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

Function debounce

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

Source from the content-addressed store, hash-verified

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

Callers 1

WidgetClass · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected