MCPcopy Create free account
hub / github.com/dethcrypto/dethcode / throttle

Function throttle

packages/ethereum-viewer/src/util/func.ts:43–59  ·  view source on GitHub ↗
(
  func: T,
  interval: number
)

Source from the content-addressed store, hash-verified

41};
42
43export const throttle = <T extends (...args: any[]) => any>(
44 func: T,
45 interval: number
46) => {
47 let timer: Timeout | null = null;
48
49 return function f(
50 this: unknown,
51 ...args: Parameters<T>
52 ): ReturnType<T> | undefined {
53 if (timer) {
54 return;
55 }
56 func.call(this, ...args);
57 timer = setTimeout(() => (timer = null), interval);
58 };
59};
60
61export const debounce = <T extends (...args: any[]) => any>(
62 func: T,

Callers 1

fetch.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected