lightning-pool 4.4.3 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +55 -13
- package/cjs/abort-error.js +0 -6
- package/cjs/definitions.js +0 -16
- package/cjs/index.js +0 -11
- package/cjs/package.json +0 -3
- package/cjs/pool-options.js +0 -128
- package/cjs/pool-request.js +0 -26
- package/cjs/pool.js +0 -476
- package/cjs/resource-item.js +0 -13
- package/esm/abort-error.js +0 -2
- package/esm/definitions.js +0 -13
- package/esm/index.js +0 -7
- package/esm/pool-options.js +0 -124
- package/esm/pool-request.js +0 -22
- package/esm/pool.js +0 -471
- package/esm/resource-item.js +0 -9
- package/typings/abort-error.d.ts +0 -2
- package/typings/definitions.d.ts +0 -34
- package/typings/index.d.ts +0 -6
- package/typings/pool-options.d.ts +0 -41
- package/typings/pool-request.d.ts +0 -11
- package/typings/pool.d.ts +0 -103
- package/typings/resource-item.d.ts +0 -11
package/package.json
CHANGED
|
@@ -1,32 +1,74 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lightning-pool",
|
|
3
3
|
"description": "Fastest generic Pool written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.6.0",
|
|
5
5
|
"author": "Panates Ltd.",
|
|
6
|
-
"contributors": [
|
|
7
|
-
"Eray Hanoglu <e.hanoglu@panates.com>"
|
|
8
|
-
],
|
|
9
6
|
"license": "MIT",
|
|
10
7
|
"repository": "panates/lightning-pool",
|
|
11
|
-
"keywords": [
|
|
12
|
-
"pool",
|
|
13
|
-
"generic",
|
|
14
|
-
"generic-pool"
|
|
15
|
-
],
|
|
16
8
|
"dependencies": {
|
|
17
9
|
"doublylinked": "^2.5.4",
|
|
18
10
|
"putil-promisify": "^1.10.1",
|
|
19
11
|
"tslib": "^2.6.3"
|
|
20
12
|
},
|
|
21
|
-
"
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@panates/eslint-config": "^1.0.16",
|
|
15
|
+
"@panates/eslint-config-ts": "^1.0.16",
|
|
16
|
+
"@panates/tsconfig": "^1.0.16",
|
|
17
|
+
"@types/jest": "^29.5.12",
|
|
18
|
+
"@types/node": "^22.2.0",
|
|
19
|
+
"dotenv": "^16.4.5",
|
|
20
|
+
"jest": "^29.7.0",
|
|
21
|
+
"npm-run-path": "^5.3.0",
|
|
22
|
+
"prettier": "^3.3.3",
|
|
23
|
+
"ts-cleanup": "^1.1.0",
|
|
24
|
+
"ts-jest": "^29.2.4",
|
|
25
|
+
"ts-loader": "^9.5.1",
|
|
26
|
+
"ts-node": "^10.9.2",
|
|
27
|
+
"tsconfig-paths": "^4.2.0",
|
|
28
|
+
"typescript": "^5.5.4"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"lint": "eslint . --max-warnings=0",
|
|
32
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
33
|
+
"format": "prettier . --write --log-level=warn",
|
|
34
|
+
"clean": "npm run clean:src && npm run clean:dist",
|
|
35
|
+
"clean:dist": "rimraf build coverage",
|
|
36
|
+
"clean:src": "ts-cleanup -s src --all | ts-cleanup -s test",
|
|
37
|
+
"prebuild": "npm run clean:dist && npm run lint",
|
|
38
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
39
|
+
"build:cjs": "tsc -b tsconfig-build-cjs.json",
|
|
40
|
+
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
41
|
+
"postbuild": "npm run postbuild:copyfiles && node ./support/postbuild.cjs",
|
|
42
|
+
"postbuild:copyfiles": "cp LICENSE README.md ./build",
|
|
43
|
+
"test": "jest --runInBand --detectOpenHandles",
|
|
44
|
+
"precover": "rimraf coverage",
|
|
45
|
+
"cover": "jest --maxWorkers=1 --coverage",
|
|
46
|
+
"precitest": "rimraf coverage",
|
|
47
|
+
"citest": "jest --coverage --coverageReporters=lcov"
|
|
48
|
+
},
|
|
22
49
|
"main": "./cjs/index.js",
|
|
23
50
|
"module": "./esm/index.js",
|
|
24
|
-
"types": "./
|
|
51
|
+
"types": "./types/index.d.ts",
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"require": "./cjs/index.js",
|
|
55
|
+
"import": "./esm/index.js",
|
|
56
|
+
"types": "./types/index.d.ts"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"contributors": [
|
|
60
|
+
"Eray Hanoglu <e.hanoglu@panates.com>"
|
|
61
|
+
],
|
|
62
|
+
"keywords": [
|
|
63
|
+
"pool",
|
|
64
|
+
"generic",
|
|
65
|
+
"generic-pool"
|
|
66
|
+
],
|
|
25
67
|
"files": [
|
|
26
68
|
"cjs/",
|
|
27
69
|
"esm/",
|
|
28
|
-
"
|
|
70
|
+
"types/",
|
|
29
71
|
"LICENSE",
|
|
30
72
|
"README.md"
|
|
31
73
|
]
|
|
32
|
-
}
|
|
74
|
+
}
|
package/cjs/abort-error.js
DELETED
package/cjs/definitions.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResourceState = exports.PoolState = void 0;
|
|
4
|
-
var PoolState;
|
|
5
|
-
(function (PoolState) {
|
|
6
|
-
PoolState[PoolState["IDLE"] = 0] = "IDLE";
|
|
7
|
-
PoolState[PoolState["STARTED"] = 1] = "STARTED";
|
|
8
|
-
PoolState[PoolState["CLOSING"] = 2] = "CLOSING";
|
|
9
|
-
PoolState[PoolState["CLOSED"] = 3] = "CLOSED";
|
|
10
|
-
})(PoolState || (exports.PoolState = PoolState = {}));
|
|
11
|
-
var ResourceState;
|
|
12
|
-
(function (ResourceState) {
|
|
13
|
-
ResourceState[ResourceState["IDLE"] = 0] = "IDLE";
|
|
14
|
-
ResourceState[ResourceState["ACQUIRED"] = 1] = "ACQUIRED";
|
|
15
|
-
ResourceState[ResourceState["VALIDATION"] = 2] = "VALIDATION";
|
|
16
|
-
})(ResourceState || (exports.ResourceState = ResourceState = {}));
|
package/cjs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPool = createPool;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pool_js_1 = require("./pool.js");
|
|
6
|
-
tslib_1.__exportStar(require("./abort-error.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./definitions.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./pool.js"), exports);
|
|
9
|
-
function createPool(factory, config) {
|
|
10
|
-
return new pool_js_1.Pool(factory, config);
|
|
11
|
-
}
|
package/cjs/package.json
DELETED
package/cjs/pool-options.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PoolOptions = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const defaultValues = {
|
|
6
|
-
acquireMaxRetries: 0,
|
|
7
|
-
acquireRetryWait: 2000,
|
|
8
|
-
acquireTimeoutMillis: 0,
|
|
9
|
-
fifo: true,
|
|
10
|
-
idleTimeoutMillis: 30000,
|
|
11
|
-
houseKeepInterval: 1000,
|
|
12
|
-
min: 0,
|
|
13
|
-
minIdle: 0,
|
|
14
|
-
max: 10,
|
|
15
|
-
maxQueue: 1000,
|
|
16
|
-
validation: true,
|
|
17
|
-
};
|
|
18
|
-
class PoolOptions extends events_1.EventEmitter {
|
|
19
|
-
constructor(pool) {
|
|
20
|
-
super();
|
|
21
|
-
this.pool = pool;
|
|
22
|
-
this._acquireMaxRetries = defaultValues.acquireMaxRetries;
|
|
23
|
-
this._acquireRetryWait = defaultValues.acquireRetryWait;
|
|
24
|
-
this._acquireTimeoutMillis = defaultValues.acquireTimeoutMillis;
|
|
25
|
-
this._fifo = defaultValues.fifo;
|
|
26
|
-
this._idleTimeoutMillis = defaultValues.idleTimeoutMillis;
|
|
27
|
-
this._houseKeepInterval = defaultValues.houseKeepInterval;
|
|
28
|
-
this._min = defaultValues.min;
|
|
29
|
-
this._minIdle = defaultValues.minIdle;
|
|
30
|
-
this._max = defaultValues.max;
|
|
31
|
-
this._maxQueue = defaultValues.maxQueue;
|
|
32
|
-
this._validation = defaultValues.validation;
|
|
33
|
-
this.pool = pool;
|
|
34
|
-
}
|
|
35
|
-
get acquireMaxRetries() {
|
|
36
|
-
return this._acquireMaxRetries;
|
|
37
|
-
}
|
|
38
|
-
set acquireMaxRetries(val) {
|
|
39
|
-
this._acquireMaxRetries = val >= 0 ? val : defaultValues.acquireMaxRetries;
|
|
40
|
-
this.emit('change', 'acquireMaxRetries', this._acquireMaxRetries);
|
|
41
|
-
}
|
|
42
|
-
get acquireRetryWait() {
|
|
43
|
-
return this._acquireRetryWait;
|
|
44
|
-
}
|
|
45
|
-
set acquireRetryWait(val) {
|
|
46
|
-
this._acquireRetryWait = val >= 0 ? val : defaultValues.acquireRetryWait;
|
|
47
|
-
this.emit('change', 'acquireRetryWait', this._acquireRetryWait);
|
|
48
|
-
}
|
|
49
|
-
get acquireTimeoutMillis() {
|
|
50
|
-
return this._acquireTimeoutMillis;
|
|
51
|
-
}
|
|
52
|
-
set acquireTimeoutMillis(val) {
|
|
53
|
-
this._acquireTimeoutMillis =
|
|
54
|
-
val >= 0 ? val : defaultValues.acquireTimeoutMillis;
|
|
55
|
-
this.emit('change', 'acquireTimeoutMillis', this._acquireTimeoutMillis);
|
|
56
|
-
}
|
|
57
|
-
get fifo() {
|
|
58
|
-
return this._fifo;
|
|
59
|
-
}
|
|
60
|
-
set fifo(val) {
|
|
61
|
-
// noinspection PointlessBooleanExpressionJS
|
|
62
|
-
this._fifo = !!val;
|
|
63
|
-
this.emit('change', 'fifo', this.fifo);
|
|
64
|
-
}
|
|
65
|
-
get idleTimeoutMillis() {
|
|
66
|
-
return this._idleTimeoutMillis;
|
|
67
|
-
}
|
|
68
|
-
set idleTimeoutMillis(val) {
|
|
69
|
-
this._idleTimeoutMillis = val >= 0 ? val : defaultValues.idleTimeoutMillis;
|
|
70
|
-
this.emit('change', 'idleTimeoutMillis', this._idleTimeoutMillis);
|
|
71
|
-
}
|
|
72
|
-
get houseKeepInterval() {
|
|
73
|
-
return this._houseKeepInterval;
|
|
74
|
-
}
|
|
75
|
-
set houseKeepInterval(val) {
|
|
76
|
-
this._houseKeepInterval = val >= 0 ? val : defaultValues.houseKeepInterval;
|
|
77
|
-
this.emit('change', 'houseKeepInterval', this._houseKeepInterval);
|
|
78
|
-
}
|
|
79
|
-
get min() {
|
|
80
|
-
return this._min;
|
|
81
|
-
}
|
|
82
|
-
set min(val) {
|
|
83
|
-
this._min = val >= 0 ? val : defaultValues.min;
|
|
84
|
-
if (this._min > this._max)
|
|
85
|
-
this._max = this._min;
|
|
86
|
-
this.emit('change', 'min', this._min);
|
|
87
|
-
}
|
|
88
|
-
get minIdle() {
|
|
89
|
-
return this._minIdle;
|
|
90
|
-
}
|
|
91
|
-
set minIdle(val) {
|
|
92
|
-
this._minIdle = val >= 0 ? val : defaultValues.minIdle;
|
|
93
|
-
this.emit('change', 'minIdle', this.minIdle);
|
|
94
|
-
}
|
|
95
|
-
get max() {
|
|
96
|
-
return this._max;
|
|
97
|
-
}
|
|
98
|
-
set max(val) {
|
|
99
|
-
this._max = val >= 0 ? Math.max(val, 1) : defaultValues.max;
|
|
100
|
-
if (this._min > this._max)
|
|
101
|
-
this._min = this._max;
|
|
102
|
-
this.emit('change', 'max', this._max);
|
|
103
|
-
}
|
|
104
|
-
get maxQueue() {
|
|
105
|
-
return this._maxQueue;
|
|
106
|
-
}
|
|
107
|
-
set maxQueue(val) {
|
|
108
|
-
this._maxQueue = val >= 0 ? Math.max(val, 1) : defaultValues.maxQueue;
|
|
109
|
-
this.emit('change', 'maxQueue', this._maxQueue);
|
|
110
|
-
}
|
|
111
|
-
get validation() {
|
|
112
|
-
return this._validation;
|
|
113
|
-
}
|
|
114
|
-
set validation(val) {
|
|
115
|
-
// noinspection PointlessBooleanExpressionJS
|
|
116
|
-
this._validation = !!val;
|
|
117
|
-
this.emit('change', 'validation', this._validation);
|
|
118
|
-
}
|
|
119
|
-
assign(values) {
|
|
120
|
-
const proto = Object.getPrototypeOf(this);
|
|
121
|
-
for (const k of Object.keys(values)) {
|
|
122
|
-
const desc = Object.getOwnPropertyDescriptor(proto, k);
|
|
123
|
-
if (desc && desc.set)
|
|
124
|
-
this[k] = values[k];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.PoolOptions = PoolOptions;
|
package/cjs/pool-request.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PoolRequest = void 0;
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
5
|
-
function noop() { }
|
|
6
|
-
class PoolRequest {
|
|
7
|
-
constructor(pool, callback, options) {
|
|
8
|
-
this.timedOut = false;
|
|
9
|
-
this.created = Date.now();
|
|
10
|
-
this.callback = callback || noop;
|
|
11
|
-
this.options = options;
|
|
12
|
-
if (pool.options.acquireTimeoutMillis) {
|
|
13
|
-
this.timeoutHandle = setTimeout(() => {
|
|
14
|
-
this.timedOut = true;
|
|
15
|
-
this.stopTimout();
|
|
16
|
-
pool.emit('request-timeout');
|
|
17
|
-
this.callback(new Error('Request timed out'));
|
|
18
|
-
}, pool.options.acquireTimeoutMillis);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
stopTimout() {
|
|
22
|
-
if (this.timeoutHandle)
|
|
23
|
-
clearTimeout(this.timeoutHandle);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.PoolRequest = PoolRequest;
|