agent-base
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -42,6 +42,10 @@ /// <reference types="node" /> | ||
requests: http.ClientRequest[]; | ||
private _promisifiedCallback?; | ||
private _defaultPort?; | ||
private promisifiedCallback?; | ||
private explicitDefaultPort?; | ||
private explicitProtocol?; | ||
constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions); | ||
defaultPort: number; | ||
get defaultPort(): number; | ||
set defaultPort(v: number); | ||
get protocol(): string; | ||
set protocol(v: string); | ||
callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void; | ||
@@ -48,0 +52,0 @@ callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>; |
@@ -5,4 +5,4 @@ "use strict"; | ||
}; | ||
const es6_promisify_1 = __importDefault(require("es6-promisify")); | ||
const events_1 = require("events"); | ||
const promisify_1 = __importDefault(require("./promisify")); | ||
function isAgentBase(v) { | ||
@@ -35,3 +35,3 @@ return Boolean(v) && typeof v.addRequest === 'function'; | ||
// The callback gets promisified lazily | ||
this._promisifiedCallback = undefined; | ||
this.promisifiedCallback = undefined; | ||
let opts = _opts; | ||
@@ -56,4 +56,4 @@ if (typeof callback === 'function') { | ||
get defaultPort() { | ||
if (typeof this._defaultPort === 'number') { | ||
return this._defaultPort; | ||
if (typeof this.explicitDefaultPort === 'number') { | ||
return this.explicitDefaultPort; | ||
} | ||
@@ -65,4 +65,15 @@ else { | ||
set defaultPort(v) { | ||
this._defaultPort = v; | ||
this.explicitDefaultPort = v; | ||
} | ||
get protocol() { | ||
if (typeof this.explicitProtocol === 'string') { | ||
return this.explicitProtocol; | ||
} | ||
else { | ||
return isSecureEndpoint() ? 'https:' : 'http:'; | ||
} | ||
} | ||
set protocol(v) { | ||
this.explicitProtocol = v; | ||
} | ||
callback(req, opts, fn) { | ||
@@ -163,11 +174,9 @@ throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`'); | ||
} | ||
if (!this._promisifiedCallback) { | ||
if (!this.promisifiedCallback) { | ||
if (this.callback.length >= 3) { | ||
// Legacy callback function - convert to a Promise | ||
this._promisifiedCallback = es6_promisify_1.default(this.callback, { | ||
thisArg: this | ||
}); | ||
this.promisifiedCallback = promisify_1.default(this.callback); | ||
} | ||
else { | ||
this._promisifiedCallback = this.callback; | ||
this.promisifiedCallback = this.callback; | ||
} | ||
@@ -182,3 +191,3 @@ } | ||
try { | ||
Promise.resolve(this._promisifiedCallback(req, opts)).then(onsocket, callbackError); | ||
Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError); | ||
} | ||
@@ -185,0 +194,0 @@ catch (err) { |
{ | ||
"name": "agent-base", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Turn a function into an `http.Agent` instance", | ||
@@ -35,3 +35,2 @@ "main": "dist/src/index", | ||
"devDependencies": { | ||
"@types/es6-promisify": "^5.0.0", | ||
"@types/mocha": "^5.2.7", | ||
@@ -56,5 +55,2 @@ "@types/node": "^10.5.3", | ||
}, | ||
"dependencies": { | ||
"es6-promisify": "^5.0.0" | ||
}, | ||
"engines": { | ||
@@ -61,0 +57,0 @@ "node": ">= 6.0.0" |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23539
0
18
8
286
0
- Removedes6-promisify@^5.0.0
- Removedes6-promise@4.2.8(transitive)
- Removedes6-promisify@5.0.0(transitive)