// Type definitions for When 2.4.0 // Project: https://github.com/cujojs/when // Definitions by: Derek Cicerone // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module When { /** * Return a promise that will resolve only once all the supplied promisesOrValues * have resolved. The resolution value of the returned promise will be an array * containing the resolution values of each of the promisesOrValues. * @memberOf when * * @param promisesOrValues array of anything, may contain a mix * of {@link Promise}s and values */ function all(promisesOrValues: any[]): Promise; /** * Creates a {promise, resolver} pair, either or both of which * may be given out safely to consumers. * The resolver has resolve, reject, and progress. The promise * has then plus extended promise API. */ function defer(): Deferred; /** * Joins multiple promises into a single returned promise. * @return a promise that will fulfill when *all* the input promises * have fulfilled, or will reject when *any one* of the input promises rejects. */ function join(...promises: Promise[]): Promise; /** * Joins multiple promises into a single returned promise. * @return a promise that will fulfill when *all* the input promises * have fulfilled, or will reject when *any one* of the input promises rejects. */ function join(...promises: any[]): Promise; /** * Returns a resolved promise. The returned promise will be * - fulfilled with promiseOrValue if it is a value, or * - if promiseOrValue is a promise * - fulfilled with promiseOrValue's value after it is fulfilled * - rejected with promiseOrValue's reason after it is rejected */ function resolve(promise: Promise): Promise; function resolve(value?: T): Promise; interface Deferred { notify(update: any): void; promise: Promise; reject(reason: any): void; resolve(value?: T): void; resolve(value?: Promise): void; } interface Promise { catch(onRejected?: (reason: any) => Promise): Promise; catch(onRejected?: (reason: any) => U): Promise; ensure(onFulfilledOrRejected: Function): Promise; inspect(): Snapshot; otherwise(onRejected?: (reason: any) => Promise): Promise; otherwise(onRejected?: (reason: any) => U): Promise; then(onFulfilled: (value: T) => Promise, onRejected?: (reason: any) => Promise, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => Promise, onRejected?: (reason: any) => U, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => U, onRejected?: (reason: any) => Promise, onProgress?: (update: any) => void): Promise; then(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U, onProgress?: (update: any) => void): Promise; } interface Snapshot { state: string; value?: T; reason?: any; } }