Socket
Socket
Sign inDemoInstall

agent-base

Package Overview
Dependencies
0
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

dist/src/promisify.d.ts

10

dist/src/index.d.ts

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc