Merge pull request #412 from AndrewGaspar/master

q for CommonJS
This commit is contained in:
Diullei Gomes
2013-03-23 17:17:09 -07:00
4 changed files with 56 additions and 2 deletions

2
Q/Q.d.ts vendored
View File

@@ -8,7 +8,7 @@ interface Qdeferred {
resolve(value: any): any;
reject(reason: any);
notify(value: any);
makeNodeResolver();
makeNodeResolver(): Function;
}
interface Qpromise {

27
Q/q.module-tests.ts Normal file
View File

@@ -0,0 +1,27 @@
/// <reference path="q.module.d.ts" />
/// <reference path="../jasmine/jasmine.d.ts" />
import q = module("q");
describe("q", function () {
it("should return", function (done) {
q({ myValue: true }).then(function (obj) {
if (obj.myValue) done();
else done("didn't work =(");
},
(err) => done(err));
});
it("should process all", function (done: (err?) => void) {
q.all([q(1), q(2), q(3)]).then(function (arr: number[]) {
var sum = arr.reduce(function (memo, cur) {
return memo + cur;
}, 0);
if (sum === 6) done();
else done({ actual: sum });
},
(err) => done(err));
});
});

26
Q/q.module.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
/// <reference path="q.d.ts" />
module "q" {
export function try(method: Function, ...args: any[]): Qpromise;
export function fbind(method: Function, ...args: any[]): Qpromise;
export function fcall(method: Function, ...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 isFulfilled(): bool;
export function isRejected(): bool;
export function isPending(): bool;
export function valueOf(): any;
export function defer(): Qdeferred;
export function (value: any): Qpromise;
export function reject(): Qpromise;
export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise;
export function isPromise(value: any): bool;
export function async(generatorFunction: any): Qdeferred;
export function nextTick(callback: Function);
export var oneerror: any;
export var longStackJumpLimit: number;
}

View File

@@ -7,7 +7,8 @@
declare function describe(description: string, specDefinitions: Function): void;
declare function xdescribe(description: string, specDefinitions: Function): void;
declare function it(expectation: string, assertion: Function): void;
declare function it(expectation: string, assertion: () => void ): void;
declare function it(expectation: string, assertion: (done: (err?) => void) => void ): void;
declare function xit(expectation: string, assertion: Function): void;
declare function beforeEach(action: Function): void;