commonly.typescript/functions
Creates a debounced version of the function argument callback
.
function debounce<Args extends any[]>(callback: (...args: Args) => void, delay = 500): (...args: Args) => void;
const debounced = debounce((str: string) => console.log(str), 1000);
debounced('one');
debounced('two');
debounced('three');
// prints `three` after 1 second