Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lightning-pool

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lightning-pool - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

77

lib/Pool.js

@@ -235,3 +235,3 @@ /* lightning-pool

this._state = PoolState.STARTED;
this._houseKeep();
this._setHouseKeep();
this._ensureMin();

@@ -264,2 +264,3 @@ this._emitSafe('start');

self._emitSafe('stopping');
self.once('stop', callback);
if (force) {

@@ -270,4 +271,3 @@ self._acquiredResources.forEach(function(t) {

}
self._houseKeep(true);
self.once('stop', callback);
self._houseKeep();
};

@@ -415,41 +415,42 @@

*/
Pool.prototype._houseKeep = function(immediate) {
if (immediate) {
clearTimeout(this._houseKeepHandle);
this._houseKeepHandle = null;
}
const isStopping = this._state === PoolState.STOPPING;
if (this._houseKeepHandle || this._state === PoolState.IDLE ||
!(isStopping || this.options.idleTimeoutMillis))
Pool.prototype._setHouseKeep = function() {
clearTimeout(this._houseKeepHandle);
this._houseKeepHandle = null;
if (this._state !== PoolState.STARTED || !this.options.houseKeepInterval)
return;
const self = this;
this._houseKeepHandle = setTimeout(function() {
self._houseKeep();
self._setHouseKeep();
}, self.options.houseKeepInterval);
};
self._houseKeepHandle = setTimeout(function() {
self._houseKeepHandle = null;
const now = Date.now();
var m = self._allResources.size - self.options.min;
var n = self._idleResources.length - self.options.minIdle;
if (isStopping || (m > 0 && n > 0)) {
self._idleResources.every(function(t) {
if (isStopping ||
t.iddleTime + self.options.idleTimeoutMillis < now) {
t.destroy();
return isStopping || ((--n) && (--m));
}
});
Pool.prototype._houseKeep = function() {
clearTimeout(this._houseKeepHandle);
const self = this;
const isStopping = self._state === PoolState.STOPPING;
const now = Date.now();
var m = self._allResources.size - self.options.min;
var n = self._idleResources.length - self.options.minIdle;
if (isStopping || (m > 0 && n > 0)) {
self._idleResources.every(function(t) {
if (isStopping ||
t.iddleTime + self.options.idleTimeoutMillis < now) {
t.destroy();
return isStopping || ((--n) && (--m));
}
});
}
if (isStopping) {
if (self._allResources.size)
/* Check again 5 ms later */
setTimeout(function() {
self._houseKeep();
}, 5);
else {
self._state = PoolState.STOPPED;
self._requestsProcessing = 0;
self._emitSafe('stop');
}
if (isStopping) {
if (self._allResources.size)
self._houseKeep();
else {
self._state = PoolState.STOPPED;
self._requestsProcessing = 0;
self._emitSafe('stop');
}
} else
self._houseKeep();
}, immediate ? 0 :
(isStopping ? 50 : self.options.houseKeepInterval));
}
};

@@ -456,0 +457,0 @@

@@ -89,3 +89,3 @@ /* lightning-pool

(val || defaultValues.idleTimeoutMillis);
this.pool._houseKeep(true);
this.pool._setHouseKeep();
},

@@ -100,3 +100,3 @@

(val || defaultValues.houseKeepInterval);
this.pool._houseKeep(true);
this.pool._setHouseKeep();
},

@@ -113,3 +113,3 @@

this._priv.max = this._priv.min;
this.pool._houseKeep(true);
this.pool._setHouseKeep();
},

@@ -124,3 +124,3 @@

(val || defaultValues.minIdle);
this.pool._houseKeep(true);
this.pool._setHouseKeep();
},

@@ -137,3 +137,3 @@

this._priv.min = this._priv.max;
this.pool._houseKeep(true);
this.pool._setHouseKeep();
},

@@ -140,0 +140,0 @@

{
"name": "lightning-pool",
"description": "Fastest object pool implementation for JavaScript",
"version": "1.0.1",
"version": "1.0.2",
"author": "Panates Ltd.",

@@ -6,0 +6,0 @@ "contributors": [

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