/** * Options for the debounce function. */ export interface DebounceOptions { /** Whether to invoke on the leading edge of the timeout. */ leading?: boolean; /** Whether to invoke on the trailing edge of the timeout. */ trailing?: boolean; } /** * A debounced function with a cancel method. */ export interface DebouncedFunction unknown> { (...arguments_: Parameters): void; /** Cancels any pending debounced invocation. */ cancel: () => void; } /** * Creates a debounced version of the provided function that delays * invoking it until after the specified wait time has elapsed since * the last time the debounced function was called. * * @param function_ - The function to debounce. * @param wait - The number of milliseconds to delay. * @param options - Configuration for leading/trailing invocation. * @param options.leading - If true, invoke on the leading edge. * @param options.trailing - If true, invoke on the trailing edge (default). * @returns The debounced function with a cancel method. * * @example * ```typescript * const debounced = debounce(() => console.log("called"), 300); * debounced(); * debounced(); * debounced.cancel(); * ``` */ export declare const debounce: unknown>(function_: T, wait: number, options?: DebounceOptions) => DebouncedFunction;