/** * Execute given functions returning promises serially. Returns a promise that resolves when all finish with they results as array. */ export declare function serial(p: (() => Promise)[]): Promise; /** iterates serially */ export declare function asyncForEach(array: any[], callback: any): Promise; /** applies a map() serially */ export declare function asyncMap(array: T[], callback: (t: T, i: number, a: T[]) => Promise): Promise; /** * Promise like object that allows to resolve it promise from outside code. Example: * ``` class Api { fooReady = new Deferred() private knower() { inOtherMoment(data=>{ this.fooReady.resolve(data) }) } } ``` */ export declare class Deferred { resolve: (r: R) => void; reject: (r: J) => void; private promise; status: 'resolved' | 'pending' | 'rejected'; constructor(callback?: (this: Deferred, resolve: (r: R) => void, reject?: (r: J) => void) => void); then(resolve: (r: R) => void): Promise; catch(r: (reject: J) => void): Promise; }