Updated q so that the interfaces fell underneath the modules

This commit is contained in:
Andrew Gaspar
2013-06-19 23:30:21 -07:00
parent a615315e63
commit a1223529d4
3 changed files with 53 additions and 54 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ Q.fcall(function () { })
}).done();
Q.allResolved([])
.then(function (promises: Qpromise[]) {
.then(function (promises: Q.Promise[]) {
promises.forEach(function (promise) {
if (promise.isFulfilled()) {
var value = promise.valueOf();
Vendored
+51 -51
View File
@@ -1,68 +1,68 @@
// Type definitions for Q
// Project: https://github.com/kriskowal/q
// Definitions by: Barrie Nemetchek
// Definitions by: Barrie Nemetchek, Andrew Gaspar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface Qdeferred {
promise: Qpromise;
resolve(value: any): any;
reject(reason: any);
notify(value: any);
makeNodeResolver(): () => void;
}
interface Qpromise {
fail(errorCallback: Function): Qpromise;
fin(finallyCallback: Function): Qpromise;
then(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Qpromise;
spread(onFulfilled: Function, onRejected?: Function): Qpromise;
catch(onRejected: Function): Qpromise;
progress(onProgress: Function): Qpromise;
done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Qpromise;
get (propertyName: String): Qpromise;
set (propertyName: String, value: any): Qpromise;
delete (propertyName: String): Qpromise;
post(methodName: String, args: any[]): Qpromise;
invoke(methodName: String, ...args: any[]): Qpromise;
keys(): Qpromise;
fapply(args: any[]): Qpromise;
fcall(method: Function, ...args: any[]): Qpromise;
timeout(ms: number): Qpromise;
delay(ms: number): Qpromise;
isFulfilled(): bool;
isRejected(): bool;
isPending(): bool;
valueOf(): any;
}
declare function Q(value: any): Qpromise;
declare function Q(value: any): Q.Promise;
declare module Q {
export function when(value: any, onFulfilled: Function, onRejected?: Function): Qpromise;
interface Deferred {
promise: Promise;
resolve(value: any): any;
reject(reason: any);
notify(value: any);
makeNodeResolver(): () => void;
}
interface Promise {
fail(errorCallback: Function): Promise;
fin(finallyCallback: Function): Promise;
then(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Promise;
spread(onFulfilled: Function, onRejected?: Function): Promise;
catch(onRejected: Function): Promise;
progress(onProgress: Function): Promise;
done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Promise;
get(propertyName: String): Promise;
set(propertyName: String, value: any): Promise;
delete(propertyName: String): Promise;
post(methodName: String, args: any[]): Promise;
invoke(methodName: String, ...args: any[]): Promise;
keys(): Promise;
fapply(args: any[]): Promise;
fcall(method: Function, ...args: any[]): Promise;
timeout(ms: number): Promise;
delay(ms: number): Promise;
isFulfilled(): bool;
isRejected(): bool;
isPending(): bool;
valueOf(): any;
}
export function when(value: any, onFulfilled: Function, onRejected?: Function): Promise;
//export function try(method: Function, ...args: any[]): Qpromise; <- This is broken currently - not sure how to fix.
export function fbind(method: Function, ...args: any[]): Qpromise;
export function fcall(method: Function, ...args: any[]): Qpromise;
export function nfbind(nodeFunction: Function): (...args: any[]) => Qpromise;
export function nfcall(nodeFunction: Function, ...args: any[]): Qpromise;
export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Qpromise;
export function all(promises: Qpromise[]): Qpromise;
export function allResolved(promises: Qpromise[]): Qpromise;
export function spread(onFulfilled: Function, onRejected: Function): Qpromise;
export function timeout(ms: number): Qpromise;
export function delay(ms: number): Qpromise;
export function delay(value: any, ms: number): Qpromise;
export function fbind(method: Function, ...args: any[]): Promise;
export function fcall(method: Function, ...args: any[]): Promise;
export function nfbind(nodeFunction: Function): (...args: any[]) => Promise;
export function nfcall(nodeFunction: Function, ...args: any[]): Promise;
export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise;
export function all(promises: Promise[]): Promise;
export function allResolved(promises: Promise[]): Promise;
export function spread(onFulfilled: Function, onRejected: Function): Promise;
export function timeout(ms: number): Promise;
export function delay(ms: number): Promise;
export function delay(value: any, ms: number): Promise;
export function isFulfilled(): bool;
export function isRejected(): bool;
export function isPending(): bool;
export function valueOf(): any;
export function defer(): Qdeferred;
export function reject(): Qpromise;
export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise;
export function defer(): Deferred;
export function reject(): Promise;
export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Promise;
export function isPromise(value: any): bool;
export function async(generatorFunction: any): Qdeferred;
export function async(generatorFunction: any): Deferred;
export function nextTick(callback: Function);
export var oneerror: any;
export var longStackJumpLimit: number;
export function resolve(object?: Qpromise);
export function resolve(object?: Promise);
}
declare module "q" {
+1 -2
View File
@@ -44,8 +44,7 @@ q.fcall(function () { })
// Handle any error from step1 through step4
}).done();
q.allResolved([])
.then(function (promises: Qpromise[]) {
q.allResolved([]).then(function (promises) {
promises.forEach(function (promise) {
if (promise.isFulfilled()) {
var value = promise.valueOf();