UNPKG

@nerjs/batchloader

Version:

`BatchLoader` is a tool for batching data requests with support for deduplication, caching, and parallel task management. It is designed to enhance flexibility and performance in scenarios requiring asynchronous data processing. This module was inspired b

15 lines (14 loc) 534 B
import { BatchLoaderFn } from '../batch-aggregator/interfaces'; import { IBatchLoaderOptions } from './interfaces'; export declare class BatchLoader<K, R> { private readonly cache; private readonly deduplicator; private readonly aggregator; private readonly getKey; constructor(batchLoaderFn: BatchLoaderFn<K, R>, options: IBatchLoaderOptions<K, R>); private readonly deduplicatorRunner; load(query: K): Promise<R>; resetCache(query: K): Promise<void>; clear(): void; flush(): Promise<void>; }