2627.js (264B)
1 /** 2 * @param {Function} fn 3 * @param {number} t milliseconds 4 * @return {Function} 5 */ 6 7 var debounce = function(fn, t) { 8 let timeout; 9 return function(...args) { 10 clearTimeout(timeout); 11 timeout = setTimeout(() => { 12 fn(...args) 13 }, t); 14 }; 15 };