export function debounce(fn, delay) { let timeout = null; return (...args) => { if (timeout) clearTimeout(timeout); timeout = setTimeout(() => { timeout = null; fn.apply(null, args); }, delay||500); } }