UNPKG

563 BTypeScriptView Raw
1interface Job {
2 resolve: (data: any) => void;
3 reject: (data: any) => void;
4 request: any;
5}
6export declare type DataloaderOptions<T> = {
7 singleLoader: (request: T) => Promise<any>;
8 batchLoader: (request: T[]) => Promise<any[]>;
9 batchBy: (request: T) => string | null;
10};
11export declare class Dataloader<T = any> {
12 private options;
13 batches: {
14 [key: string]: Job[];
15 };
16 private tickActive;
17 constructor(options: DataloaderOptions<T>);
18 request(request: T): Promise<any>;
19 private dispatchBatches;
20}
21export {};