Skip to content

Commit 62d8d7e

Browse files
committed
refactor: Addition to previous commit containing debounce work
1 parent e6bf16d commit 62d8d7e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/utils/debounce.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
export function debounce (fn, wait = 250, immediate) {
33
let timeout
44

5-
// Prevents execution of debounced function, or noop if
6-
// never invoked/already executed
7-
function cancel () {
8-
if (timeout) {
9-
clearTimeout(timeout)
10-
}
11-
}
12-
135
function debounced (...args) {
146
const later = () => {
157
timeout = null
@@ -25,7 +17,10 @@ export function debounce (fn, wait = 250, immediate) {
2517
timeout = setTimeout(later, wait)
2618
}
2719

28-
debounced.cancel = cancel
20+
debounced.cancel = () => {
21+
clearTimeout(timeout)
22+
}
23+
2924
return debounced
3025
}
3126

0 commit comments

Comments
 (0)