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/).

15 lines (13 loc) 361 B
export function throttle<T extends (...args: any[]) => void>( func: T, timeFrame: number, ): (...args: Parameters<T>) => void { let lastTime = 0; return function (this: any, ...args: Parameters<T>) { const now = new Date(); if (now.getTime() - lastTime >= timeFrame) { func.apply(this, args); lastTime = now.getTime(); } }; }