UNPKG

@lzptec/concurrency

Version:

A Lightweight concurrency manager

19 lines (17 loc) 538 B
type SemaphoreOptions = { maxConcurrency: number; }; type SemaphoreLock = { release: () => void; }; declare class Semaphore { #private; constructor(options?: SemaphoreOptions); run<B>(task: () => (B | Promise<B>)): Promise<B>; run<A extends Array<any>, B>(task: (...args: A) => (B | Promise<B>), ...args: A): Promise<B>; acquire(): Promise<SemaphoreLock>; get acquired(): number; get options(): SemaphoreOptions; set options(options: SemaphoreOptions); } export { Semaphore, type SemaphoreLock };