UNPKG

@ava/cooperate

Version:

Plugin to enable cooperation between AVA test files

52 lines (51 loc) 1.88 kB
import { SemaphoreCreationFailed } from './types.js'; export declare class Lock { #private; readonly id: string; constructor(context: SharedContext, id: string); acquire(): Promise<() => void>; acquireNow(): Promise<() => void>; } export declare class LockAcquisitionError extends Error { readonly lockId: string; get name(): string; constructor(lockId: string); } export declare class ManagedSemaphore { #private; readonly id: string; readonly initialValue: number; constructor(context: SharedContext, id: string, initialValue: number); acquire(amount?: number): Promise<(release?: number) => void>; acquireNow(amount?: number): Promise<(release?: number) => void>; } export declare class UnmanagedSemaphore { #private; readonly id: string; readonly initialValue: number; constructor(context: SharedContext, id: string, initialValue: number); down(amount?: number): Promise<void>; downNow(amount?: number): Promise<void>; up(amount?: number): Promise<undefined>; } declare type Semaphore = ManagedSemaphore | UnmanagedSemaphore; export declare class SemaphoreDownError extends Error { readonly semaphoreId: string; readonly amount: number; get name(): string; constructor(semaphoreId: string, amount: number); } export declare class SemaphoreCreationError extends Error { readonly semaphoreId: string; get name(): string; constructor(semaphore: Semaphore, reason: SemaphoreCreationFailed); } export declare class SharedContext { readonly id: string; constructor(id: string); createLock(id: string): Lock; createSemaphore(id: string, initialValue: number): ManagedSemaphore; createUnmanagedSemaphore(id: string, initialValue: number): UnmanagedSemaphore; reserve<T extends bigint | number | string>(...values: T[]): Promise<T[]>; } export {};