froebel
Version:
TypeScript utility library
18 lines (17 loc) • 619 B
TypeScript
import type { λ } from "./types";
export declare const cancel: unique symbol;
/**
* Creates a debounced function that delays invoking `fun` until `ms` milliseconds
* have passed since the last invocation of the debounced function.
*
* `fun` is invoked with the last arguments passed to the debounced function.
*
* Calling `[debounce.cancel]()` on the debounced function will cancel the currently
* scheduled invocation.
*/
declare const debounce: (<T extends λ<any[], any>>(fun: T, ms: number) => λ<Parameters<T>, void> & {
[cancel](): void;
}) & {
cancel: typeof cancel;
};
export default debounce;