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

Function debounce

packages/ethereum-viewer/src/util/func.ts:61–73  ·  view source on GitHub ↗
(
  func: T,
  milliseconds: number
)

Source from the content-addressed store, hash-verified

59};
60
61export const debounce = <T extends (...args: any[]) => any>(
62 func: T,
63 milliseconds: number
64) => {
65 let timer: Timeout | undefined;
66
67 return function f(this: unknown, ...args: Parameters<T>): void {
68 if (timer) {
69 clearTimeout(timer);
70 }
71 timer = setTimeout(() => func.call(this, ...args), milliseconds);
72 };
73};
74
75// debounce an async func. once an async func canceled, it throws a exception
76export const debounceAsyncFunc = <T extends (...args: any[]) => Promise<any>>(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected