froebel
Version:
TypeScript utility library
20 lines (19 loc) • 609 B
TypeScript
import type { λ } from "./types";
export declare const cancel: unique symbol;
/**
* Create a throttled function that invokes `fun` at most every `ms` milliseconds.
*
* `fun` is invoked with the last arguments passed to the throttled function.
*
* Calling `[throttle.cancel]()` on the throttled function will cancel the currently
* scheduled invocation.
*/
declare const throttle: (<T extends λ<any[], any>>(fun: T, ms: number, opts?: {
leading?: boolean;
trailing: boolean;
}) => λ<Parameters<T>, void> & {
[cancel](): void;
}) & {
cancel: typeof cancel;
};
export default throttle;