MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / debounce

Function debounce

apps/site/util/objects.ts:3–16  ·  view source on GitHub ↗
(
  func: T,
  delay: number
)

Source from the content-addressed store, hash-verified

1type DebounceFunction<T = unknown> = (...args: Array<T>) => void;
2
3export const debounce = <T extends DebounceFunction>(
4 func: T,
5 delay: number
6): ((...args: Parameters<T>) => void) => {
7 let timeoutId: NodeJS.Timeout;
8
9 return (...args: Parameters<T>) => {
10 clearTimeout(timeoutId);
11
12 timeoutId = setTimeout(() => {
13 func(...args);
14 }, delay);
15 };
16};
17
18export function deepMerge<Obj1 extends object, Obj2 extends object>(
19 obj1: Obj1,

Callers 1

objects.test.mjsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected