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

Function debounce

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

Source from the content-addressed store, hash-verified

760 * @returns Debounced function
761 */
762export function debounce<T extends (...args: unknown[]) => unknown>(
763 fn: T,
764 delay: number
765): (...args: Parameters<T>) => void {
766 let timeoutId: ReturnType<typeof setTimeout> | null = null;
767
768 return (...args: Parameters<T>) => {
769 if (timeoutId) {
770 clearTimeout(timeoutId);
771 }
772 timeoutId = setTimeout(() => {
773 fn(...args);
774 timeoutId = null;
775 }, delay);
776 };
777}
778
779/**
780 * Throttle a function

Callers 1

WidgetClass · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected