We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 59487ac commit dc3e8c1Copy full SHA for dc3e8c1
src/utils/debounce.ts
@@ -5,10 +5,14 @@
5
* @param { number } wait Time to wait before execut the function
6
* @param { boolean } immediate Param to define if the function will be executed immediately
7
*/
8
-const debounce = (func: (...args: any[]) => void, wait?: number, immediate?: boolean) => {
+const debounce = <T, A extends any[]>(
9
+ func: (...args: A) => void,
10
+ wait?: number,
11
+ immediate?: boolean,
12
+) => {
13
let timeout: NodeJS.Timeout | null = null
14
- return function debounced(this: typeof func, ...args: any[]) {
15
+ return function debounced(this: T, ...args: A): void {
16
const later = () => {
17
timeout = null
18
if (!immediate) {
0 commit comments