YingXingAI/common/utils.js

17 lines
364 B
JavaScript
Raw Permalink Normal View History

2025-06-30 14:43:02 +08:00
export const Debounce = (fn, wait) => {
let delay = wait|| 500
let timer
return function () {
let args = arguments;
if (timer) {
clearTimeout(timer)
}
let callNow = !timer
timer = setTimeout(() => {
timer = null
}, delay)
if (callNow) fn.apply(this, args)
}
}