1 | type AnyFunction = (...arguments_: readonly any[]) => unknown;
|
2 |
|
3 | /**
|
4 | Creates a debounced function that delays execution until `wait` milliseconds have passed since its last invocation.
|
5 |
|
6 | Set the `immediate` option to `true` to invoke the function immediately at the start of the `wait` interval, preventing issues such as double-clicks on a button.
|
7 |
|
8 | The returned function has a `.clear()` method to cancel scheduled executions, and a `.flush()` method for immediate execution and resetting the timer for future calls.
|
9 | */
|
10 | declare function debounce<F extends AnyFunction>(
|
11 | function_: F,
|
12 | wait?: number,
|
13 | options?: {immediate: boolean}
|
14 | ): debounce.DebouncedFunction<F>;
|
15 |
|
16 | declare namespace debounce {
|
17 | type DebouncedFunction<F extends AnyFunction> = {
|
18 | (...arguments_: Parameters<F>): ReturnType<F> | undefined;
|
19 | clear(): void;
|
20 | flush(): void;
|
21 | };
|
22 | }
|
23 |
|
24 | export = debounce;
|