14 lines
253 B
JavaScript
14 lines
253 B
JavaScript
![]() |
export function debounce (func, wait) {
|
||
|
let timeout
|
||
|
|
||
|
return function executedFunction (...args) {
|
||
|
const later = () => {
|
||
|
clearTimeout(timeout)
|
||
|
func(...args)
|
||
|
}
|
||
|
|
||
|
clearTimeout(timeout)
|
||
|
timeout = setTimeout(later, wait)
|
||
|
}
|
||
|
}
|