UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

35 lines (34 loc) 1.28 kB
/** * Timing helpers for delaying / rate-limiting function calls. * * `debounce` and `throttle` are drop-in replacements for the equivalent * lodash exports (`debounce` supports `{ leading, trailing, maxWait }`, * `throttle` supports `{ leading, trailing }`). * * Both return an instance of `DebouncedFunction<T>` which exposes * `cancel()` and `flush()` for managing pending invocations. */ export interface DebounceOptions { leading?: boolean; trailing?: boolean; maxWait?: number; } export interface DebouncedFunction<T extends (...args: any[]) => any> { (...args: Parameters<T>): ReturnType<T> | undefined; cancel(): void; flush(): ReturnType<T> | undefined; } export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, options?: DebounceOptions): DebouncedFunction<T>; export interface ThrottleOptions { leading?: boolean; trailing?: boolean; } /** * Implemented in terms of `debounce` with `maxWait` (same approach as lodash). */ export declare function throttle<T extends (...args: any[]) => any>(func: T, wait?: number, options?: ThrottleOptions): DebouncedFunction<T>; export declare const TimingHelper: { debounce: typeof debounce; throttle: typeof throttle; }; export default TimingHelper;