repod/src/utils/debounce.js
Michel Roux b0a0414fd4
All checks were successful
repod / xml (push) Successful in 1m25s
repod / php (push) Successful in 45s
repod / nodejs (push) Successful in 1m30s
repod / release (push) Has been skipped
refactor: 🎨 add prettier and update deps
2024-04-30 00:48:47 +02:00

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)
}
}