13 lines
276 B
JavaScript
13 lines
276 B
JavaScript
// https://stackoverflow.com/a/53486112
|
|
export const debounce = (fn, delay) => {
|
|
let timeoutID = null
|
|
return function () {
|
|
clearTimeout(timeoutID)
|
|
const args = arguments
|
|
const that = this
|
|
timeoutID = setTimeout(function () {
|
|
fn.apply(that, args)
|
|
}, delay)
|
|
}
|
|
}
|