//#region src/util/RequestBatcher.d.ts /** * @internal * A data structure that represents a possible process and how to handle it. */ interface WaitingProcess { name: string; args: Args; perform: (...args: Args) => Promise; awaitingResolutions: ((returnValue: Return) => void)[]; awaitingRejections: ((err: any) => void)[]; after?: (result: Return) => void; } declare const ANY_KEY = "any"; /** * Options for processes that are waiting to execute */ interface WaitingProcessOptions { /** * The name of the process like "read" or "delete" */ name: string; /** * The arguements supplied to the process */ args: Args; /** * A function that will be triggered when it's time to execute this process * @param args - arguments supplied to the process * @returns a return type */ perform: (...args: Args) => Promise; /** * A custom function to modify the queue based on the current state of the * queue * @param processQueue - The current process queue * @param currentlyProcessing - The Process that is currently executing * @param args - provided args * @returns A WaitingProcess that this request should listen to, or undefined * if it should create its own */ modifyQueue: (processQueue: WaitingProcess[], currentlyProcessing: WaitingProcess | undefined, args: Args) => WaitingProcess | undefined; after?: (result: Return) => void; } /** * @internal * A utility for batching a request */ declare class RequestBatcher { /** * A mapping between a process key and the last time in UTC a process of that * key was executed. */ private lastRequestTimestampMap; /** * A pointer to the current process the batcher is working on */ private currentlyProcessing; /** * A queue of upcoming processes */ private processQueue; /** * The amount of time (in milliseconds) between requests of the same key */ batchMillis: number; /** * @param options - options, including the value for batchMillis */ constructor(options?: Partial<{ batchMillis: number; }>); /** * Check if the request batcher is currently working on a process * @param key - the key of the process to check * @returns true if the batcher is currently working on the provided process */ isLoading(key: string): boolean; /** * Triggers the next process in the queue or triggers a timeout to wait to * execute the next process in the queue if not enough time has passed since * the last process was triggered. */ private triggerOrWaitProcess; /** * Adds a process to the queue and waits for the process to be complete * @param options - WaitingProcessOptions * @returns A promise that resolves when the process resolves */ queueProcess(options: WaitingProcessOptions): Promise; } //#endregion export { ANY_KEY, RequestBatcher, WaitingProcess, WaitingProcessOptions }; //# sourceMappingURL=RequestBatcher.d.cts.map