@inkline/inkline
Version:
Inkline is the Vue.js UI/UX Library built for creating your next design system
20 lines • 708 B
JavaScript
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked, or until the next browser frame is drawn.
*
* @param fn
* @param delay
* @returns {Function}
*/
export function debounce(fn, delay) {
let inDebounce;
return function (...args) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const context = this; // eslint-disable-line @typescript-eslint/no-this-alias, no-invalid-this
clearTimeout(inDebounce);
inDebounce = setTimeout(() => fn.apply(context, args), delay);
};
}
//# sourceMappingURL=debounce.mjs.map