// Global variable exported in browsers. export as namespace promiseBreaker; declare namespace PromiseBreaker { interface MakeBreakOptions { args?: number; } type Callback = (err: Error | null | undefined, result?: R) => void; interface BrokenFn0 { (): Promise; (cb: Callback): void; } interface BrokenFn1 { (p1: T1): Promise; (p1: T1, cb: Callback): void; } interface BrokenFn2 { (p1: T1, p2: T2): Promise; (p1: T1, p2: T2, cb: Callback): void; } interface BrokenFn3 { (p1: T1, p2: T2, p3: T3): Promise; (p1: T1, p2: T2, p3: T3, cb: Callback): void; } interface PromiseBreakerInstance { make(options: MakeBreakOptions, asyncFn: (cb: Callback) => void): BrokenFn0; make( options: MakeBreakOptions, asyncFn: (p1: T1, cb: Callback) => void ): BrokenFn1; make( options: MakeBreakOptions, asyncFn: (p1: T1, p2: T2, cb: Callback) => void ): BrokenFn2; make( options: MakeBreakOptions, asyncFn: (p1: T1, p2: T2, p3: T3, cb: Callback) => void ): BrokenFn3; make( options: MakeBreakOptions, asyncFn: (...args: any[]) => any ): (...args: any[]) => Promise; make(asyncFn: (cb: Callback) => void): BrokenFn0; make(asyncFn: (p1: T1, cb: Callback) => void): BrokenFn1; make(asyncFn: (p1: T1, p2: T2, cb: Callback) => void): BrokenFn2; make( asyncFn: (p1: T1, p2: T2, p3: T3, cb: Callback) => void ): BrokenFn3; make(asyncFn: (...args: any[]) => any): (...args: any[]) => Promise; break(options: MakeBreakOptions, promiseFn: () => PromiseLike): BrokenFn0; break( options: MakeBreakOptions, promiseFn: (p1: T1) => PromiseLike ): BrokenFn1; break( options: MakeBreakOptions, promiseFn: (p1: T1, p2: T2) => PromiseLike ): BrokenFn2; break( options: MakeBreakOptions, promiseFn: (p1: T1, p2: T2, p3: T3) => PromiseLike ): BrokenFn3; break( options: MakeBreakOptions, promiseFn: (...args: any[]) => any ): (...args: any[]) => Promise; break(promiseFn: () => PromiseLike): BrokenFn0; break(promiseFn: (p1: T1) => PromiseLike): BrokenFn1; break(promiseFn: (p1: T1, p2: T2) => PromiseLike): BrokenFn2; break( promiseFn: (p1: T1, p2: T2, p3: T3) => PromiseLike ): BrokenFn3; break(promiseFn: (...args: any[]) => any): (...args: any[]) => Promise; addPromise( done: Callback | undefined | null, asyncFn: (cb: Callback) => void ): Promise; addCallback( done: Callback | undefined | null, promise: (() => Promise) | (() => R) | Promise ): Promise; apply(fn: Function, thisArg?: any, args?: any[] | undefined): Promise; apply(fn: Function, thisArg: any, args: any[] | undefined, done: Function): void; call(fn: Function, thisArg?: any, ...parameters: any[]): Promise; callWithCb(fn: Function, thisArg: any, ...parametersAndCallback: any[]): void; } interface PromiseBreaker extends PromiseBreakerInstance { withPromise(promiseImpl: PromiseConstructor): PromiseBreaker; } } declare const PromiseBreaker: PromiseBreaker.PromiseBreaker; export default PromiseBreaker; export function make( options: PromiseBreaker.MakeBreakOptions, asyncFn: (cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn0; export function make( options: PromiseBreaker.MakeBreakOptions, asyncFn: (p1: T1, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn1; export function make( options: PromiseBreaker.MakeBreakOptions, asyncFn: (p1: T1, p2: T2, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn2; export function make( options: PromiseBreaker.MakeBreakOptions, asyncFn: (p1: T1, p2: T2, p3: T3, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn3; export function make( options: PromiseBreaker.MakeBreakOptions, asyncFn: (...args: any[]) => any ): (...args: any[]) => Promise; export function make( asyncFn: (cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn0; export function make( asyncFn: (p1: T1, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn1; export function make( asyncFn: (p1: T1, p2: T2, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn2; export function make( asyncFn: (p1: T1, p2: T2, p3: T3, cb: PromiseBreaker.Callback) => void ): PromiseBreaker.BrokenFn3; export function make(asyncFn: (...args: any[]) => any): (...args: any[]) => Promise; export function addPromise( done: PromiseBreaker.Callback | undefined | null, asyncFn: (cb: PromiseBreaker.Callback) => void ): Promise; export function addCallback( done: PromiseBreaker.Callback | undefined | null, promise: (() => Promise) | (() => R) | Promise ): Promise; export function apply(fn: Function, thisArg?: any, args?: any[] | undefined): Promise; export function apply(fn: Function, thisArg: any, args: any[] | undefined, done: Function): void; export function call(fn: Function, thisArg?: any, ...parameters: any[]): Promise; export function callWithCb(fn: Function, thisArg: any, ...parametersAndCallback: any[]): void;