Path: blob/master/node_modules/@adiwajshing/baileys/lib/Utils/event-buffer.d.ts
1129 views
import { Logger } from 'pino';1import { AuthenticationCreds, BaileysEventEmitter, BaileysEventMap } from '../Types';2/**3* A map that contains a list of all events that have been triggered4*5* Note, this can contain different type of events6* this can make processing events extremely efficient -- since everything7* can be done in a single transaction8*/9declare type BaileysEventData = Partial<BaileysEventMap<AuthenticationCreds>>;10declare type BaileysBufferableEventEmitter = BaileysEventEmitter & {11/** Use to process events in a batch */12process(handler: (events: BaileysEventData) => void | Promise<void>): (() => void);13/**14* starts buffering events, call flush() to release them15* @returns true if buffering just started, false if it was already buffering16* */17buffer(): boolean;18/** buffers all events till the promise completes */19createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): ((...args: A) => Promise<T>);20/** flushes all buffered events */21flush(): Promise<void>;22/** waits for the task to complete, before releasing the buffer */23processInBuffer(task: Promise<any>): any;24};25/**26* The event buffer logically consolidates different events into a single event27* making the data processing more efficient.28* @param ev the baileys event emitter29*/30export declare const makeEventBuffer: (logger: Logger) => BaileysBufferableEventEmitter;31export {};323334