Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

throttle.js

14 lines299 Bytes

1export const throttle = (func, limit) => {
2 let inThrottle;
3 return function () {
4 const args = arguments; // @ts-ignore
5​
6 const context = this;
7​
8 if (!inThrottle) {
9 func.apply(context, args);
10 inThrottle = true;
11 setTimeout(() => inThrottle = false, limit);
12 }
13 };
14};