Skip to content

Instantly share code, notes, and snippets.

@tcelestino
Created September 28, 2020 13:42
Show Gist options
  • Save tcelestino/522296674d193737f05d71c572af0535 to your computer and use it in GitHub Desktop.
Save tcelestino/522296674d193737f05d71c572af0535 to your computer and use it in GitHub Desktop.
simple debounce
let timeout;
const debounce = (func, wait) => {
clearTimeout(timeout);
timeout = setTimeout(func, wait);
};
const handleInput = () => {
debounce(() => {
format();
setCaret();
}, 200);
};
container.addEventListener("input", handleInput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment