Wreck 7.0.0 typings - fixes

This commit is contained in:
Marcin Porebski
2015-11-27 13:53:54 +01:00
parent 0dd5ad7c0f
commit 117d429754
2 changed files with 13 additions and 19 deletions
+4 -6
View File
@@ -2,7 +2,7 @@
import Wreck = require('wreck');
Wreck.get('https://google.com/', function (err, res, payload) {
Wreck.get('https://google.com/', {}, function (err: any, res: any, payload: any) {
/* do stuff */
});
@@ -23,17 +23,15 @@ var wreckWithTimeout = wreck.defaults({
// all attributes are optional
var options = {
maxBytes: 1048576, // 1 MB, default: unlimited
rejectUnauthorized: true,
downstreamRes: null,
agent: null, // Node Core http.Agent
rejectUnauthorized: true
};
var optionalCallback = function (err, res) {
var optionalCallback = function (err: any, res: any) {
/* handle err if it exists, in which case res will be undefined */
// buffer the response stream
Wreck.read(res, null, function (err, body) {
Wreck.read(res, null, function (err: any, body: any) {
/* do stuff */
});
};
+9 -13
View File
@@ -5,7 +5,7 @@
/// <reference path="../node/node.d.ts" />
declare module Wreck
declare module "wreck"
{
import http = require('http');
import stream = require('stream');
@@ -15,17 +15,17 @@ declare module Wreck
{
defaults: (options: any) => IWreckObject;
request: (method: string, uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage) => void = null) => http.ClientRequest;
request: (method: string, uri: string, options: any, callback?: (err: any, response: http.IncomingMessage) => void) => http.ClientRequest;
read: (response: http.IncomingMessage, options: any, callback: (err: any, payload: any) => void) => void;
get: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest;
post: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest;
patch: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest;
put: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest;
delete: (uri: string, options: any = null, callback: (err: any, response: http.IncomingMessage, payload: any) => void = null) => http.ClientRequest;
get: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
post: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
patch: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
put: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
delete: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest;
toReadableStream: (payload: any, encoding: string = null) => stream.Readable;
toReadableStream: (payload: any, encoding?: string) => stream.Readable;
parseCacheControl: (field: string) => any;
@@ -35,11 +35,7 @@ declare module Wreck
};
}
}
declare module "wreck"
{
var wreck: Wreck.IWreckObject;
var wreck: IWreckObject;
export = wreck;
}