@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
17 lines (16 loc) • 846 B
TypeScript
import type { AnyToAnyFnSignature } from '../misc/functions';
/** Throttled<F> is a function wrapper type for a function decorated via throttle */
export interface Throttled<F extends AnyToAnyFnSignature> {
/** Throttled method signature */
(...args: Parameters<F>): void;
/** Promise of throttled function call */
promise: Promise<ReturnType<F> | void>;
}
/**
* Creates a throttled executed function.
* The func is invoked with the last arguments provided to the throttled function.
* @param fn - function to decorate
* @param threshold - indicates how often function could be called
* @param thisArg - optional context to call original function, use debounced method call context if not defined
*/
export declare function throttle<F extends AnyToAnyFnSignature>(fn: F, threshold?: number, thisArg?: object): Throttled<F>;