type FixedSizeArray = T extends 0 ? void[] : ReadonlyArray & { 0: U; length: T; }; type Measure = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never; type Append = { 0: [U]; 1: [T[0], U]; 2: [T[0], T[1], U]; 3: [T[0], T[1], T[2], U]; 4: [T[0], T[1], T[2], T[3], U]; 5: [T[0], T[1], T[2], T[3], T[4], U]; 6: [T[0], T[1], T[2], T[3], T[4], T[5], U]; 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U]; 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U]; }[Measure]; export type AsArray = T extends any[] ? T : [T]; export type Fn = (...args: AsArray) => R; export type FnWithCallback = (...args: Append, InnerCallback>) => void; declare class UnsetAdditionalOptions { _UnsetAdditionalOptions: true; } type IfSet = X extends UnsetAdditionalOptions ? {} : X; type Callback = (error: E | null, result?: T) => void; type InnerCallback = (error?: E | null | false, result?: T) => void; type FullTap = Tap & { type: "sync" | "async" | "promise"; fn: Function; }; type Tap = TapOptions & { name: string; }; type TapOptions = { before?: string; stage?: number; }; export type Options = string | (Tap & IfSet); export interface HookInterceptor { name?: string; tap?: (tap: FullTap & IfSet) => void; call?: (...args: any[]) => void; loop?: (...args: any[]) => void; error?: (err: Error) => void; result?: (result: R) => void; done?: () => void; register?: (tap: FullTap & IfSet) => FullTap & IfSet; } type ArgumentNames = FixedSizeArray; declare class Hook { args?: ArgumentNames>; name?: string; taps: (FullTap & IfSet)[]; interceptors: HookInterceptor[]; constructor(args?: ArgumentNames>, name?: string); intercept(interceptor: HookInterceptor): void; _runRegisterInterceptors(options: FullTap & IfSet): FullTap & IfSet; _runCallInterceptors(...args: any[]): void; _runErrorInterceptors(e: Error): void; _runTapInterceptors(tap: FullTap & IfSet): void; _runDoneInterceptors(): void; isUsed(): boolean; queryStageRange(stageRange: StageRange): QueriedHook; callAsyncStageRange(queried: QueriedHook, ...args: Append, Callback>): void; callAsync(...args: Append, Callback>): void; promiseStageRange(queried: QueriedHook, ...args: AsArray): Promise; promise(...args: AsArray): Promise; tap(options: Options, fn: Fn): void; _tap(type: "sync" | "async" | "promise", options: Options, fn: Function): void; _insert(item: FullTap & IfSet): void; } export type StageRange = readonly [number, number]; export declare const minStage: number; export declare const maxStage: number; export declare const safeStage: (stage: number) => number; export declare class QueriedHook { stageRange: StageRange; hook: Hook; tapsInRange: (FullTap & IfSet)[]; constructor(stageRange: StageRange, hook: Hook); isUsed(): boolean; call(...args: AsArray): R; callAsync(...args: Append, Callback>): void; promise(...args: AsArray): Promise; } export declare class SyncHook extends Hook { callAsyncStageRange(queried: QueriedHook, ...args: Append, Callback>): void; call(...args: AsArray): R; callStageRange(queried: QueriedHook, ...args: AsArray): R; tapAsync(): never; tapPromise(): never; } export declare class AsyncParallelHook extends Hook { callAsyncStageRange(queried: QueriedHook, ...args: Append, Callback>): void; tapAsync(options: Options, fn: FnWithCallback): void; tapPromise(options: Options, fn: Fn): void; } export declare class AsyncSeriesHook extends Hook { callAsyncStageRange(queried: QueriedHook, ...args: Append, Callback>): void; tapAsync(options: Options, fn: FnWithCallback): void; tapPromise(options: Options, fn: Fn): void; } export {};