13 lines
267 B
JavaScript
Raw Normal View History

2024-05-03 09:40:35 +00:00
export function throttle(fn, delay) {
let timeout = null;
return function (...args) {
if (timeout === null) {
fn(...args);
timeout = setTimeout(() => {
timeout = null;
}, delay);
}
};
}