1
0
Fork 0
react-playground/node_modules/@mui/x-internals/esm/throttle/throttle.js
Techognito fc0f69dacb Added Statistics calculation
Statistics now show calculated values
2025-09-04 17:30:00 +02:00

19 lines
No EOL
396 B
JavaScript

export function throttle(func, wait = 166) {
let timeout;
let lastArgs;
const later = () => {
timeout = undefined;
func(...lastArgs);
};
function throttled(...args) {
lastArgs = args;
if (timeout === undefined) {
timeout = setTimeout(later, wait);
}
}
throttled.clear = () => {
clearTimeout(timeout);
timeout = undefined;
};
return throttled;
}