{
function debounce(fn, ms) {
let timer
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => fn(...args),ms)
}
}
const log = debounce((text) => console.log('search:', text), 300);
log('r');
log('re');
log('rea');
// через 300 мс после последнего вызова: search: rea
}
Code will run automatically after changes.