export interface DeferredResolver { /** * Returns a reference to the controlled promise that can be passed to clients. */ promise: Promise; /** * Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state. */ resolve(value: R): void; resolve(): void; /** * Reject the underlying promise with `reason` as the rejection reason. */ reject(reason: any): void; /** * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. * The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. * * If the the callback is called with multiple success values, the resolver fulfills its promise with an array of the values. */ callback(err: any, value: R, ...values: R[]): void; } /** * A deferred promise that can be resolved or rejected * externally, ideal for functions like a promise timeout */ export declare class Deferred { static delay(millis: number): Promise; static resolve(value?: T): Deferred; private result; private cancelCallback; private state; readonly promise: Promise; constructor(promise?: Promise | undefined); isSettled(): boolean; isCancelled(): boolean; cancel(): void; getResult(): T; onCancel(cancelCallback: DeferredCancelCallback): void; resolve(result?: T | undefined): void; reject(err: any): void; } export declare type DeferredCancelCallback = (deferred: Deferred) => void; export default Deferred;