@waboyz-baileys/shared
Version:
27 lines (26 loc) • 793 B
TypeScript
type DebounceCallback<T> = (key: string, data: T) => void;
type ExpireCallback<T> = (key: string, data: T) => void;
interface DebouncerOptions<T> {
delay: number;
expireAfter?: number;
maxSize?: number;
onExpire?: ExpireCallback<T>;
}
export declare class PerKeyDebouncer<T> {
private map;
private readonly delay;
private readonly expireAfter?;
private readonly maxSize;
private readonly onExpire?;
private readonly callback;
constructor(callback: DebounceCallback<T>, options: DebouncerOptions<T>);
push(key: string, data: T): void;
get(key: string): T | undefined;
has(key: string): boolean;
cancel(key: string): void;
flush(key: string): void;
clear(): void;
size(): number;
entries(): [string, T][];
}
export {};