typedash
Version:
modern, type-safe collection of utility functions
26 lines (25 loc) • 1.16 kB
text/typescript
import { t as AnyFunction } from "./AnyFunction-C6KudB8p.cjs";
//#region src/functions/debounce/debounce.d.ts
/**
* Creates a debounced function that delays invoking `func` until after `delay` milliseconds have elapsed since the last time the debounced function was invoked.
* @param func The function to debounce.
* @param delay The number of milliseconds to delay.
* @param options Optional configuration options.
* @param options.leading Whether to call the function on the leading edge of the timeout.
* @returns A debounced function that can be called multiple times, but only invokes `func` once per `delay` milliseconds.
*/
declare function debounce<TFunction extends AnyFunction<void | undefined>>(func: TFunction, delay: number, options?: {
/**
* Whether to call the function on the leading edge of the timeout.
* @default false
*/
leading?: boolean;
}): DebouncedFunction<TFunction>;
interface DebouncedFunction<TFunction extends AnyFunction<void | undefined>> {
(...args: Parameters<TFunction>): void;
clear(): void;
flush(): void;
}
//#endregion
export { debounce as t };
//# sourceMappingURL=debounce-DtZoWDZ0.d.cts.map