anylang
Version:
A translator's kit that uses the free APIs of Google Translate, Yandex, Bing, ChatGPT, and other LLMs
28 lines (27 loc) • 628 B
TypeScript
interface Options {
timeout?: number;
hijackPrevention?: boolean;
}
export interface ISemaphore {
take(): Promise<() => void>;
}
/**
* Semaphore for the flow control in queues
*
* @example
* const semafor = QueueSemafor({ timeout: 100 });
* items.map(async item=> {
* const free = await semafor.take();
* // do something with item...
* free();
* })
*/
export declare class Semaphore implements ISemaphore {
private readonly timeout;
private readonly hijackPrevention;
constructor(options?: Options);
private lastAccess;
private semafor;
take(): Promise<() => void>;
}
export {};