MCPcopy
hub / github.com/darkreader/darkreader / debounce

Function debounce

src/utils/debounce.ts:3–14  ·  view source on GitHub ↗
(delay: number, fn: F)

Source from the content-addressed store, hash-verified

1type AnyFn = (...args: any[]) => void;
2
3export function debounce<F extends AnyFn>(delay: number, fn: F): F {
4 let timeoutId: ReturnType<typeof setTimeout> | null = null;
5 return ((...args: any[]) => {
6 if (timeoutId) {
7 clearTimeout(timeoutId);
8 }
9 timeoutId = setTimeout(() => {
10 timeoutId = null;
11 fn(...args);
12 }, delay);
13 }) as F;
14}

Callers 2

UserStorageClass · 0.90
ExtensionClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected