agent-base
Advanced tools
Comparing version 4.0.0 to 4.0.1
4.0.1 / 2017-06-13 | ||
================== | ||
* add `this` context tests and fixes | ||
4.0.0 / 2017-06-06 | ||
@@ -3,0 +8,0 @@ ================== |
10
index.js
@@ -40,7 +40,2 @@ 'use strict'; | ||
if (this.callback.length >= 3) { | ||
// legacy callback function, convert to Promise | ||
this.callback = promisify(this.callback); | ||
} | ||
// timeout for the socket to be returned from the callback | ||
@@ -134,2 +129,7 @@ this.timeout = (opts && opts.timeout) || null; | ||
if (this.callback.length >= 3) { | ||
// legacy callback function, convert to Promise | ||
this.callback = promisify(this.callback, this); | ||
} | ||
if (timeoutMs > 0) { | ||
@@ -136,0 +136,0 @@ timeout = setTimeout(ontimeout, timeoutMs); |
{ | ||
"name": "agent-base", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Turn a function into an `http.Agent` instance", | ||
@@ -26,4 +26,4 @@ "main": "./index.js", | ||
"devDependencies": { | ||
"mocha": "3", | ||
"ws": "0.8.0" | ||
"mocha": "^3.4.2", | ||
"ws": "^3.0.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
@@ -47,2 +47,24 @@ /** | ||
}); | ||
describe('`this` context', function() { | ||
it('should be the Agent instance', function(done) { | ||
var agent = new Agent(); | ||
agent.callback = function () { | ||
assert.equal(this, agent); | ||
done(); | ||
} | ||
var info = url.parse('http://127.0.0.1/foo'); | ||
info.agent = agent; | ||
http.get(info); | ||
}) | ||
it('should be the Agent instance with callback signature', function(done) { | ||
var agent = new Agent(); | ||
agent.callback = function (req, opts, fn) { | ||
assert.equal(this, agent); | ||
done(); | ||
} | ||
var info = url.parse('http://127.0.0.1/foo'); | ||
info.agent = agent; | ||
http.get(info); | ||
}) | ||
}) | ||
describe('"error" event', function() { | ||
@@ -49,0 +71,0 @@ it('should be invoked on `http.ClientRequest` instance if `callback()` has not been defined', function( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28875
653