This commit is contained in:
Paul van Brenk
2017-03-22 13:54:08 -07:00
3 changed files with 114 additions and 123 deletions
+1 -2
View File
@@ -1,6 +1,5 @@
import chai = require('chai');
import chaiAsPromised = require('chai-as-promised');
import Q = require('q');
chai.use(chaiAsPromised);
@@ -45,7 +44,7 @@ thenableNum.should.be.fulfilled.then(function () {
thenableNum.should.equal("after");
}).should.notify(() => console.log('done'));
Q.all([
Promise.all([
thenableNum.should.become("happy"),
thenableNum.should.eventually.have.property("fun times"),
thenableNum.should.be.rejectedWith(TypeError, "only joyful types are allowed")
+109 -117
View File
@@ -2,125 +2,117 @@
// Project: https://github.com/haoxins/fetch.io
// Definitions by: newraina <https://github.com/newraina>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="whatwg-fetch" />
type TUrl = string;
type TUrl = string;
type TMethod = 'delete' | 'get' | 'head' | 'options' | 'post' | 'put';
type TMethod = 'delete' | 'get' | 'head' | 'options' | 'post' | 'put';
interface Query {
[key: string]: number | boolean | string;
}
interface Header {
[key: string]: string;
}
interface Options extends RequestInit {
prefix?: string;
query?: Query;
header?: Header;
beforeRequest?(url: TUrl, body: BodyInit): boolean;
afterResponse?(res: Response): void;
afterJSON?(body: any): void;
}
declare namespace FetchIo {
class Request {
constructor(method: TMethod, url: TUrl, options: Options)
/**
* HTTP delete method
*/
delete: (url: TUrl) => this;
/**
* HTTP get method
*/
get: (url: TUrl) => this;
/**
* HTTP head method
*/
head: (url: TUrl) => this;
/**
* HTTP options method
*/
options: (url: TUrl) => this;
/**
* HTTP post method
*/
post: (url: TUrl) => this;
/**
* HTTP put method
*/
put: (url: TUrl) => this;
/**
* Set Options
*/
config(key: string, value: any): this
config(opts: {[key: string]: any}): this
/**
* Set Header
*/
set(key: string, value: any): this
set(opts: {[key: string]: any}): this
/**
* Set Content-Type
*/
type(type: 'json' | 'form' | 'urlencoded'): this
/**
* Add query string
*/
query(object: {[key: string]: any}): this
/**
* Send data
*/
send(data: {[key: string]: any}): this
/**
* ppend formData
*/
append(key: string, value: string): this
/**
* Get Response directly
*/
then(resolve: (value?: Response) => void, reject?: (reason?: any) => void): Promise<any>
/**
* Make Response to JSON
*/
json(strict?: boolean): Promise<any>
/**
* Make Response to string
*/
text(): Promise<string>
}
class Fetch extends Request {
constructor(options?: Options)
}
interface Query {
[key: string]: number | boolean | string;
}
export default FetchIo.Fetch;
interface Header {
[key: string]: string;
}
interface Options extends RequestInit {
prefix?: string;
query?: Query;
header?: Header;
beforeRequest?(url: TUrl, body: BodyInit): boolean;
afterResponse?(res: Response): void;
afterJSON?(body: any): void;
}
declare class Request {
constructor(method: TMethod, url: TUrl, options: Options)
/**
* HTTP delete method
*/
delete: (url: TUrl) => this;
/**
* HTTP get method
*/
get: (url: TUrl) => this;
/**
* HTTP head method
*/
head: (url: TUrl) => this;
/**
* HTTP options method
*/
options: (url: TUrl) => this;
/**
* HTTP post method
*/
post: (url: TUrl) => this;
/**
* HTTP put method
*/
put: (url: TUrl) => this;
/**
* Set Options
*/
config(key: string, value: any): this
config(opts: {[key: string]: any}): this
/**
* Set Header
*/
set(key: string, value: any): this
set(opts: {[key: string]: any}): this
/**
* Set Content-Type
*/
type(type: 'json' | 'form' | 'urlencoded'): this
/**
* Add query string
*/
query(object: {[key: string]: any}): this
/**
* Send data
*/
send(data: {[key: string]: any}): this
/**
* ppend formData
*/
append(key: string, value: string): this
/**
* Get Response directly
*/
then(resolve: (value?: Response) => void, reject?: (reason?: any) => void): Promise<any>
/**
* Make Response to JSON
*/
json(strict?: boolean): Promise<any>
/**
* Make Response to string
*/
text(): Promise<string>
}
export default class Fetch extends Request {
constructor(options?: Options)
}
+4 -4
View File
@@ -118,10 +118,10 @@ interface WebGLVertexArrayObjectOES extends WebGLObject {
interface OESVertexArrayObject {
VERTEX_ARRAY_BINDING_OES: number;
createVertexArrayOES(): WebGLVertexArrayObjectOES;
deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void;
isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): boolean;
bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void;
createVertexArrayOES(): WebGLVertexArrayObjectOES | null;
deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): boolean;
bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES | null): void;
}
interface WebGLColorBufferFloat {