mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
Add specialized overloads for request events
This commit is contained in:
@@ -640,3 +640,15 @@ request({url: 'http://www.google.com', jar: j}, function () {
|
||||
var cookies = j.getCookies(url);
|
||||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
|
||||
});
|
||||
|
||||
request(
|
||||
{ method: 'GET'
|
||||
, uri: 'http://www.google.com'
|
||||
, gzip: true
|
||||
}
|
||||
)
|
||||
.on('request', function(req: http.ClientRequest) { })
|
||||
.on('response', function(resp: http.IncomingMessage) { })
|
||||
.on('data', function(data: Buffer | string) { })
|
||||
.on('error', function(e: Error) { })
|
||||
.on('complete', function(resp: http.IncomingMessage, body?: string | Buffer) { });
|
||||
7
request/request.d.ts
vendored
7
request/request.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for request
|
||||
// Project: https://github.com/mikeal/request
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>, Christopher Currens <https://github.com/ccurrens>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
|
||||
@@ -180,6 +180,11 @@ declare module 'request' {
|
||||
jar(jar: CookieJar): Request;
|
||||
|
||||
on(event: string, listener: Function): Request;
|
||||
on(event: 'request', listener: (req: http.ClientRequest) => void): Request;
|
||||
on(event: 'response', listener: (resp: http.IncomingMessage) => void): Request;
|
||||
on(event: 'data', listener: (data: Buffer | string) => void): Request;
|
||||
on(event: 'error', listener: (e: Error) => void): Request;
|
||||
on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): Request;
|
||||
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
|
||||
Reference in New Issue
Block a user