Problem
Implement debounce(fn, wait, options) where options is { leading, trailing }:
leading: true→ invoke on the first call of a burst (immediately).trailing: true→ invoke after the burst settles (default).- both true → invoke at the start and end of a burst.
function debounce(fn, wait, { leading = false, trailing = true } = {}) {
// your code
}