@speckle/shared
Version:
Shared code between various Speckle JS packages
31 lines • 1.51 kB
TypeScript
/**
* Utility for batching async operations. Useful when you have thousands of async operations and you can't
* just invoke them all at once because of resource constraints (e.g. network bandwidth).
*
* 'operationParams' should be an array of parameters for each async operation. The size of this array coresponds
* to the amount of async operations that will be invoked.
* 'operationPromiseGenerator' will be invoked sequentially with each params of 'operationParams' and with it
* you can specify what the actual async operation should be
*
* TODO: Some tests would be nice, although it does work when tested through `yarn cli download commit` in speckle-server
*/
export declare function batchAsyncOperations<Params = unknown, Res = unknown>(name: string, operationParams: Params[], operationPromiseGenerator: (params: Params) => Promise<Res>, options?: Partial<{
/**
* If promise returned by generator fails, re-execute it this many times
*/
retryCount: number;
/**
* How many concurrent promises can be executed at once
*/
batchSize: number;
/**
* Optionally override the logger with a custom one
*/
logger: (...args: any[]) => void;
/**
* If set to true, the function won't collect all of the returns of each operation in an effort to reduce
* memory usage. The function will return 'true' instead of an array of results.
*/
dropReturns: boolean;
}>): Promise<true | Res[] | undefined>;
//# sourceMappingURL=batch.d.ts.map