export function throttle(func, delay) { let lastTime = 0; return function(...args) { const now = Date.now(); if (now - lastTime >= delay) { func.apply(this, args); lastTime = now; } } } export function debounceThrottle(func, wait, immediate) { let timeout, previous = 0; return function (...args) { const now = Date.now(); const later = () => { timeout = null; if (!immediate) func.apply(this, args); }; const callNow = immediate && !timeout; clearTimeout(timeout); if (now - previous > wait) { previous = now; if (callNow) func.apply(this, args); } timeout = setTimeout(later, wait); }; }