New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lightning-request-net

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightning-request-net - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test.js

10

connection.js

@@ -11,5 +11,10 @@ const net = require('net');

keepAlive: true,
timeout: 60 * 1000,
};
}
get destroyed() {
return this.socket.destroyed;
}
constructor(options = {}) {

@@ -36,2 +41,3 @@ this.options = Object.assign(this.defaultOptions, options);

this.socket = new net.Socket();
this.socket.setTimeout(this.options.timeout);
this.socket.setKeepAlive(this.options.keepAlive);

@@ -113,2 +119,3 @@ this.socket.connect(this.options.port, this.options.host);

debug('socket event -> timeout');
this.socket.end();
})

@@ -137,5 +144,2 @@ .on('drain', () => {

}
setTimeout(() => {
this.socket.connect(this.options.port, this.options.host);
}, 3000);
});

@@ -142,0 +146,0 @@ }

@@ -10,8 +10,3 @@ const Connection = require('./connection');

this.options = options || {};
this.options.poolOptions = Object.assign(
{
min: 100,
},
this.options.poolOptions || {}
);
this.options.poolOptions = Object.assign({}, this.options.poolOptions || {});

@@ -18,0 +13,0 @@ const factory = {

{
"name": "lightning-request-net",
"version": "0.0.1",
"version": "0.0.2",
"description": "Lightweight Node.js HTTP client based on net.",

@@ -5,0 +5,0 @@ "main": "index.js",

class Pool {
get defaultOptions() {
return {
min: 100,
initialValue: 10,
};

@@ -16,4 +16,4 @@ }

init() {
const min = this.options.min;
for (let i = 0; i < min; i++) {
const initialValue = this.options.initialValue;
for (let i = 0; i < initialValue; i++) {
this.resources.push(this.factory.create());

@@ -27,3 +27,9 @@ }

}
return this.resources.pop();
const conn = this.resources.pop();
// 判断该连接是否已销毁,如果已销毁,则重新申请,直到申请到一个未销毁的连接
if (!conn.destroyed) {
return conn;
} else {
return this.acquire();
}
}

@@ -30,0 +36,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc