Socket
Socket
Sign inDemoInstall

generic-pool

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generic-pool - npm Package Compare versions

Comparing version 3.4.0 to 3.4.1

8

CHANGELOG.md
# Change Log
## [3.4.1] - Febuary 1 2018
- prevent timed-out resource requests from being issued resources (@rebareba)
## [3.4.0] - December 27 2017

@@ -170,3 +173,6 @@ - #218 fix numerous docblock annotations and minor errors in internal classes (@geovanisouza92)

=======
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.3.0...HEAD
[unreleased]: https://github.com/coopernurse/node-pool/compare/v3.4.1...HEAD
[3.4.1]: https://github.com/coopernurse/node-pool/compare/v3.4.0...v3.4.1
[3.4.0]: https://github.com/coopernurse/node-pool/compare/v3.3.0...v3.4.0
[3.3.0]: https://github.com/coopernurse/node-pool/compare/v3.2.0...v3.3.0

@@ -173,0 +179,0 @@ [3.2.0]: https://github.com/coopernurse/node-pool/compare/v3.1.8...v3.2.0

@@ -12,2 +12,3 @@ "use strict";

const Deque = require("./Deque");
const Deferred = require("./Deferred");
const PriorityQueue = require("./PriorityQueue");

@@ -264,3 +265,6 @@ const DequeIterator = require("./DequeIterator");

const clientResourceRequest = this._waitingClientsQueue.dequeue();
if (clientResourceRequest === undefined) {
if (
clientResourceRequest === undefined ||
clientResourceRequest.state !== Deferred.PENDING
) {
// While we were away either all the waiting clients timed out

@@ -267,0 +271,0 @@ // or were somehow fulfilled. put our pooledResource back.

2

package.json
{
"name": "generic-pool",
"description": "Generic resource pooling for Node.JS",
"version": "3.4.0",
"version": "3.4.1",
"author": "James Cooper <james@bitmechanic.com>",

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

@@ -571,9 +571,3 @@ "use strict";

tap.test("returns only valid object to the pool", function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -608,12 +602,3 @@ pool

tap.test("validate acquires object from the pool", function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -633,12 +618,3 @@ pool

tap.test("release to pool should work", function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -671,12 +647,3 @@ pool

function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -698,12 +665,3 @@ pool

function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -726,12 +684,3 @@ pool

tap.test("destroy should redispense", function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {},
max: 1
});
const pool = createPool(new ResourceFactory(), { max: 1 });

@@ -762,17 +711,6 @@ pool

tap.test("evictor start with acquire when autostart is false", function(t) {
const pool = createPool(
{
create: function() {
return Promise.resolve({ id: "validId" });
},
validate: function(resource) {
return Promise.resolve(true);
},
destroy: function(client) {}
},
{
evictionRunIntervalMillis: 10000,
autostart: false
}
);
const pool = createPool(new ResourceFactory(), {
evictionRunIntervalMillis: 10000,
autostart: false
});

@@ -793,12 +731,5 @@ t.equal(pool._scheduledEviction, null);

tap.test("use method", function(t) {
const pool = createPool({
create: function() {
return Promise.resolve({
id: "validId"
});
},
destroy: function(client) {}
});
const pool = createPool(new ResourceFactory());
const result = pool.use(function(resource) {
t.equal("validId", resource.id);
t.equal(0, resource.id);
return Promise.resolve();

@@ -805,0 +736,0 @@ });

@@ -7,22 +7,23 @@ const Pool = require("../lib/Pool");

*/
var ResourceFactory = function ResourceFactory() {
this.created = 0;
this.destroyed = 0;
this.bin = [];
};
class ResourceFactory {
constructor() {
this.created = 0;
this.destroyed = 0;
this.bin = [];
}
ResourceFactory.prototype.create = function() {
var id = this.created++;
var resource = {
id: id
};
return Promise.resolve(resource);
};
create() {
return Promise.resolve({ id: this.created++ });
}
ResourceFactory.prototype.destroy = function(resource) {
this.destroyed++;
this.bin.push(resource);
return Promise.resolve();
};
validate() {
return Promise.resolve(true);
}
destroy(resource) {
this.destroyed++;
this.bin.push(resource);
return Promise.resolve();
}
}
exports.ResourceFactory = ResourceFactory;

@@ -29,0 +30,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