UNPKG

@shopware-ag/meteor-component-library

Version:

The meteor component library is a Vue component library developed by Shopware. It is based on the [Meteor Design System](https://shopware.design/).

17 lines (14 loc) 428 B
export function debounce<T extends (...args: any[]) => void>( func: T, delay: number, ): (...args: any[]) => void { let timeoutId: ReturnType<typeof setTimeout>; return function (this: any, ...args: any[]) { // eslint-disable-next-line @typescript-eslint/no-this-alias const context = this; clearTimeout(timeoutId); timeoutId = setTimeout(() => { func.apply(context, args); }, delay); }; }