#1493·es-toolkit

Proposal for safer and clearer debounce/throttle edges option

Author: DominikSerafinCreated Oct 22, 2025Updated Jun 19, 2026
Labelsp3: discussionnext major

Problem

Both es-toolkit and lodash allow users to disable leading and trailing options at the same time on the debounce and throttle functions.

This effectively makes the functions no-ops (with a certain exception in lodash's throttle).

Neither library documents this behavior, and I cannot think of any use case for this. There's also this related lodash issue.

On top of that, I also find the DX of the edges options in both libraries a bit unintuitive because of the way they're set through objects/arrays.

Reproduction

The following code will not log anything to the console:

typescript
import {debounce, throttle} from 'es-toolkit';
import {debounce as compatDebounce, throttle as compatThrottle} from 'es-toolkit/compat';

const debounced = debounce(
  () => console.log('debounced'),
  1000,
  {edges: []}
);

const throttled = throttle(
  () => console.log('throttled'),
  1000,
  {edges: []}
);

const compatDebounced = compatDebounce(
  () => console.log('compatDebounced'),
  1000,
  {leading: false, trailing: false}
);

const compatThrottled = compatThrottle(
  () => console.log('compatThrottled'),
  1000,
  {leading: false, trailing: false}
);

debounced(); 
compatDebounced();

throttled(); 
compatThrottled(); 

The only case where something gets executed is in the case of subsequent lodash throttle calls after initial wait time:

typescript
const compatThrottled = compatThrottle(
  () => console.log('compatThrottled'),
  1000,
  {leading: false, trailing: false}
);

compatThrottled(); 
setTimeout(compatThrottled, 1000 + 1);

Solution

Redesign the way edges are configured by allowing only one of the following: trailing, leading, or both.

Rough outline/usage:

typescript
type Edges = 'leading' | 'trailing' | 'both'; 

debounce(fn, ms, {edges: 'leading'});
debounce(fn, ms, {edges: 'trailing'});
debounce(fn, ms, {edges: 'both'});

Maybe the edges could also be renamed to a more suitable name that works better with mixed singular and plural values, e.g. mode, trigger, activation, invokeOn, callTiming, or something else along these lines.