2023-07-27 23:57:37 +00:00
|
|
|
// https://stackoverflow.com/a/53486112
|
|
|
|
export const debounce = (fn, delay) => {
|
2023-07-25 23:26:46 +00:00
|
|
|
let timeoutID = null
|
2024-04-29 22:48:47 +00:00
|
|
|
return function () {
|
2023-07-25 23:26:46 +00:00
|
|
|
clearTimeout(timeoutID)
|
|
|
|
const args = arguments
|
|
|
|
const that = this
|
2024-04-29 22:48:47 +00:00
|
|
|
timeoutID = setTimeout(function () {
|
2023-07-25 23:26:46 +00:00
|
|
|
fn.apply(that, args)
|
|
|
|
}, delay)
|
|
|
|
}
|
|
|
|
}
|