/** * Trailing-edge debounce and leading-plus-trailing throttle. * * Ported from maker-ds `form-inputs/combobox-shared/debounce.ts`, for the reason its * own header gives: pulling `lodash-es` in for two functions would drag a transitive * install into every consumer of this package. * * Not exported from the package. `scripts/generate-exports.mjs` only publishes a * directory with an `index.ts`, and `internal/` deliberately has none — these exist to * serve the combobox's async modes, and promoting them to public API is a separate * decision from needing them here. */ export interface Debounced { (...args: TArgs): void; /** Drop any pending invocation. */ cancel: () => void; /** Invoke a pending call immediately. A no-op when nothing is pending. */ flush: () => void; } export interface Throttled { (...args: TArgs): void; /** Drop any pending trailing invocation. Already-invoked leading calls stand. */ cancel: () => void; } /** * Delay `fn` until `wait` ms have passed without another call. Trailing edge only, * and the most recent arguments win. * * The return value of `fn` is discarded, so a debounced async function returns * `void` rather than a promise — there is no single promise to hand back when calls * collapse into one. Callers that need the result should await the underlying * function, which is why the hooks below expose both forms. */ export declare function debounce(fn: (...args: TArgs) => unknown, wait: number): Debounced; /** * Invoke `fn` immediately, then at most once per `wait` ms, with a trailing call * carrying the last arguments seen during the window. * * The trailing timer is scheduled for the time *remaining* in the window rather than * a full `wait`, so the throttle period stays honest regardless of when the last call * inside it arrived. */ export declare function throttle(fn: (...args: TArgs) => unknown, wait: number): Throttled; //# sourceMappingURL=debounce.d.ts.map