Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit de7c3bb

Browse files
author
Je
committed
refactor: improve util.debounce method
1 parent b54994b commit de7c3bb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ export default {
119119
cleanPath(path: string): string {
120120
return '/' + this.splitPath(path).join('/')
121121
},
122-
debounce(callback: () => void, delay: number) {
122+
debounce<T extends Function>(callback: T, delay: number): T {
123123
let timer: number | null = null
124-
return () => {
124+
return ((...args: any[]) => {
125125
if (timer != null) {
126126
clearTimeout(timer)
127127
}
128128
timer = setTimeout(() => {
129129
timer = null
130-
callback()
130+
callback(...args)
131131
}, delay)
132-
}
132+
}) as any
133133
},
134134
debounceX(id: string, callback: () => void, delay: number) {
135135
const self = this as any

0 commit comments

Comments
 (0)