Build a Debounce Utility with Configurable Leading and Trailing Edge Firing
Extend the basic debounce to accept an options object supporting leading (fire on the first call immediately) and trailing (fire after the last call's delay expires) boolean flags. When leading is true, the function runs at the start of the quiet period; when trailing is true, it fires at the end. Handle cases where both are true (fire at both edges), both false (no-op), and rapid successive calls that might otherwise fire multiple times.