import { Func } from '../types.ts'; export interface DebounceOptions { delay: number; maxWait?: number; } export interface DebouncedFunction { (...args: Parameters): void; flush(): ReturnType | undefined; cancel(): void; } /** * Delays the last call of a function for `delay` * milliseconds and ignores all subsequent calls * until the delay has passed. * * @param fn function to debounce * @param opts options for the debounce function * @returns debounced function with flush and cancel methods * * @example * const debouncedFn = debounce(fn, { delay: 1000 }); * debouncedFn(); // ignored * await wait(500); * debouncedFn(); // ignored * await wait(500); * debouncedFn(); // will call fn after 1000ms * * // Enhanced interface * const result = debouncedFn.flush(); // execute immediately * debouncedFn.cancel(); // prevent execution */ export declare const debounce: (fn: T, opts: DebounceOptions) => DebouncedFunction;