lightning-pool 4.3.0 → 4.4.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/README.md CHANGED
@@ -121,13 +121,7 @@ Acquires a `resource` from the `Pool` or create a new one.
121
121
 
122
122
  ##### Usage
123
123
 
124
- `pool.acquire(): Promise<any>`
125
-
126
- `pool.acquire(factoryCreateOptions: any): Promise<any>`
127
-
128
- `pool.acquire(callback:Callback): Promise<any>`
129
-
130
- `pool.acquire(factoryCreateOptions?: any, callback:Callback): Promise<any>`
124
+ `pool.acquire()`
131
125
 
132
126
  - *Returns*: A Promise
133
127
 
@@ -4,11 +4,10 @@ exports.PoolRequest = void 0;
4
4
  // eslint-disable-next-line @typescript-eslint/no-empty-function
5
5
  function noop() { }
6
6
  class PoolRequest {
7
- constructor(pool, callback, options) {
7
+ constructor(pool, callback) {
8
8
  this.timedOut = false;
9
9
  this.created = Date.now();
10
10
  this.callback = callback || noop;
11
- this.options = options;
12
11
  if (pool.options.acquireTimeoutMillis) {
13
12
  this.timeoutHandle = setTimeout(() => {
14
13
  this.timedOut = true;
package/cjs/pool.js CHANGED
@@ -155,17 +155,7 @@ class Pool extends events_1.EventEmitter {
155
155
  closeAsync(arg0) {
156
156
  return putil_promisify_1.default.fromCallback(cb => this.close(arg0, cb));
157
157
  }
158
- acquire(arg0, arg1) {
159
- let callback;
160
- let factoryCreateOptions;
161
- if (typeof arg0 === 'function') {
162
- callback = arg0;
163
- }
164
- else if (typeof arg0 === 'object') {
165
- factoryCreateOptions = arg0;
166
- if (typeof arg1 === 'function')
167
- callback = arg1;
168
- }
158
+ acquire(callback) {
169
159
  if (!callback)
170
160
  return putil_promisify_1.default.fromCallback(cb => this.acquire(cb));
171
161
  try {
@@ -177,7 +167,7 @@ class Pool extends events_1.EventEmitter {
177
167
  if (this.options.maxQueue && this.pending >= this.options.maxQueue) {
178
168
  return callback(new Error('Pool queue is full'));
179
169
  }
180
- this._requestQueue.push(new pool_request_js_1.PoolRequest(this, callback, factoryCreateOptions));
170
+ this._requestQueue.push(new pool_request_js_1.PoolRequest(this, callback));
181
171
  this._processNextRequest();
182
172
  }
183
173
  /**
@@ -331,7 +321,7 @@ class Pool extends events_1.EventEmitter {
331
321
  };
332
322
  const tryCreate = () => {
333
323
  try {
334
- const o = this._factory.create({ tries, maxRetries }, request?.options);
324
+ const o = this._factory.create({ tries, maxRetries });
335
325
  /* istanbul ignore next */
336
326
  if (!o) {
337
327
  return handleCallback(new abort_error_js_1.AbortError('Factory returned no resource'));
@@ -1,11 +1,10 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-empty-function
2
2
  function noop() { }
3
3
  export class PoolRequest {
4
- constructor(pool, callback, options) {
4
+ constructor(pool, callback) {
5
5
  this.timedOut = false;
6
6
  this.created = Date.now();
7
7
  this.callback = callback || noop;
8
- this.options = options;
9
8
  if (pool.options.acquireTimeoutMillis) {
10
9
  this.timeoutHandle = setTimeout(() => {
11
10
  this.timedOut = true;
package/esm/pool.js CHANGED
@@ -151,17 +151,7 @@ export class Pool extends EventEmitter {
151
151
  closeAsync(arg0) {
152
152
  return promisify.fromCallback(cb => this.close(arg0, cb));
153
153
  }
154
- acquire(arg0, arg1) {
155
- let callback;
156
- let factoryCreateOptions;
157
- if (typeof arg0 === 'function') {
158
- callback = arg0;
159
- }
160
- else if (typeof arg0 === 'object') {
161
- factoryCreateOptions = arg0;
162
- if (typeof arg1 === 'function')
163
- callback = arg1;
164
- }
154
+ acquire(callback) {
165
155
  if (!callback)
166
156
  return promisify.fromCallback(cb => this.acquire(cb));
167
157
  try {
@@ -173,7 +163,7 @@ export class Pool extends EventEmitter {
173
163
  if (this.options.maxQueue && this.pending >= this.options.maxQueue) {
174
164
  return callback(new Error('Pool queue is full'));
175
165
  }
176
- this._requestQueue.push(new PoolRequest(this, callback, factoryCreateOptions));
166
+ this._requestQueue.push(new PoolRequest(this, callback));
177
167
  this._processNextRequest();
178
168
  }
179
169
  /**
@@ -327,7 +317,7 @@ export class Pool extends EventEmitter {
327
317
  };
328
318
  const tryCreate = () => {
329
319
  try {
330
- const o = this._factory.create({ tries, maxRetries }, request?.options);
320
+ const o = this._factory.create({ tries, maxRetries });
331
321
  /* istanbul ignore next */
332
322
  if (!o) {
333
323
  return handleCallback(new AbortError('Factory returned no resource'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lightning-pool",
3
3
  "description": "Fastest generic Pool written with TypeScript",
4
- "version": "4.3.0",
4
+ "version": "4.4.0",
5
5
  "author": "Panates Ltd.",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>"