export type ThrottledCallback = (...args: unknown[]) => unknown; export type ThrottledFunction = (...args: T) => void; /** * Throttle a function so it runs at most once per `timeout` ms. * * - `leading`: fire immediately when the window opens * - `trailing`: remember the latest args/this and fire once when the window closes * * defaults: `{ leading: true, trailing: false }` * * notes: * - make one throttled instance and reuse it; re-creating it resets internal state * * @typeParam T - the function type being throttled * @param fn - function to throttle * @param timeout - minimum time between invocations (ms) * @param options - behavior switches * @param options.leading - call on the leading edge (default: true) * @param options.trailing - call once at the end of the window with the latest args (default: false) * @returns a throttled function with the same call signature as `fn` * * @example * const send = (payload: Data) => api.post('/endpoint', payload); * const sendThrottled = throttle(send, 2000, { leading: true, trailing: true }); * // call `sendThrottled` freely; it won’t invoke `send` more than once every 2s */ export declare const throttle: (fn: (...args: T) => void, timeout?: number, { leading, trailing, }?: { leading?: boolean; trailing?: boolean; }) => { throttledFn: (this: unknown, ...args: T) => void; cancelTimer: () => void; }; //# sourceMappingURL=throttle.d.ts.map