/**
 * Creates a throttled function that only invokes func at most once per
 * every wait milliseconds. The throttled function comes with a cancel
 * method to cancel delayed func invocations and a flush method to
 * immediately invoke them.
 *
 * Supports options: { leading, trailing }
 * Drop-in replacement for lodash/throttle.
 *
 * Implemented using debounce with maxWait (same approach as lodash).
 */
import debounce from './debounce';
export default function throttle(func, wait = 0, options) {
    return debounce(func, wait, {
        leading: options?.leading ?? true,
        trailing: options?.trailing ?? true,
        maxWait: wait,
    });
}
