@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
37 lines (36 loc) • 1.3 kB
JavaScript
var m = Object.defineProperty;
var T = (i, e, t) => e in i ? m(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var c = (i, e, t) => (T(i, typeof e != "symbol" ? e + "" : e, t), t);
const u = class u {
/**
* Set a global debounce timeout value. NOTE: Set this to 0 to disable debounce & receive all input events immediately.
* This is useful for testing purposes.
*
* @param debounceTimeout The debounce timeout in milliseconds.
*/
static setGlobalDebounceTimeout(e) {
u.debounceTimeout = e;
}
/**
* Debounce a function, i.e. prevent triggering the function until a certain amount of time has passed without further
* input.
*
* @param fn Function to debounce.
* @param timeout Debounce timeout in milliseconds, uses the global setting by default.
*
* @returns Debounced function or in the case the timeout is set to 0 the original function parameter.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static debounce(e, t = u.debounceTimeout) {
let o;
return t > 0 ? (...a) => {
o && clearTimeout(o), o = window.setTimeout(() => e(...a), t);
} : e;
}
};
c(u, "debounceTimeout", 300);
let r = u;
export {
r as NeonDebounceUtils
};
//# sourceMappingURL=NeonDebounceUtils.es.js.map