12 lines
166 B
JavaScript
12 lines
166 B
JavaScript
|
function debounce(f,wait)
|
||
|
{
|
||
|
let timeout
|
||
|
|
||
|
return function(...args){
|
||
|
clearTimeout(timeout)
|
||
|
timeout=setTimeout(()=>f(...args),wait)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default debounce
|