lightning-pool 4.8.0 → 4.10.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/cjs/pool.js CHANGED
@@ -36,14 +36,14 @@ class Pool extends events_1.EventEmitter {
36
36
  throw new TypeError('factory.reset can be a function');
37
37
  }
38
38
  const opts = (this._options = new pool_options_js_1.PoolOptions(this));
39
+ if (config)
40
+ this.options.assign(config);
39
41
  opts.on('change', (prop, val) => {
40
42
  if (prop === 'houseKeepInterval')
41
43
  this._setHouseKeep(val);
42
44
  if (prop === 'min' || prop === 'minIdle')
43
45
  this._ensureMin();
44
46
  });
45
- if (config)
46
- this.options.assign(config);
47
47
  this._factory = factory;
48
48
  }
49
49
  /**
@@ -440,25 +440,25 @@ class Pool extends events_1.EventEmitter {
440
440
  _itemDestroy(item, callback) {
441
441
  this._itemDetach(item);
442
442
  const handleCallback = (err) => {
443
- if (err) {
444
- this.emit('destroy-error', err, item.resource);
445
- /* istanbul ignore next */
446
- return callback && callback(err);
447
- }
448
- this.emit('destroy', item.resource);
449
443
  item.destroyed = true;
444
+ this._allResources.delete(item.resource);
445
+ if (err)
446
+ this.emit('destroy-error', err, item.resource);
447
+ else
448
+ this.emit('destroy', item.resource);
450
449
  if (callback)
451
- callback();
450
+ callback(err);
452
451
  };
453
452
  try {
454
- this._allResources.delete(item.resource);
455
- this._processNextRequest();
456
453
  const o = this._factory.destroy(item.resource);
457
454
  putil_promisify_1.default.await(o, handleCallback);
458
455
  }
459
456
  catch (e) {
460
457
  handleCallback(e);
461
458
  }
459
+ finally {
460
+ this._processNextRequest();
461
+ }
462
462
  }
463
463
  _itemValidate(item, callback) {
464
464
  item.state = definitions_js_1.ResourceState.VALIDATION;
@@ -0,0 +1 @@
1
+ {"root":["../../src/abort-error.ts","../../src/definitions.ts","../../src/index.ts","../../src/pool-options.ts","../../src/pool-request.ts","../../src/pool.ts","../../src/resource-item.ts"],"version":"5.6.3"}
package/esm/pool.js CHANGED
@@ -32,14 +32,14 @@ export class Pool extends EventEmitter {
32
32
  throw new TypeError('factory.reset can be a function');
33
33
  }
34
34
  const opts = (this._options = new PoolOptions(this));
35
+ if (config)
36
+ this.options.assign(config);
35
37
  opts.on('change', (prop, val) => {
36
38
  if (prop === 'houseKeepInterval')
37
39
  this._setHouseKeep(val);
38
40
  if (prop === 'min' || prop === 'minIdle')
39
41
  this._ensureMin();
40
42
  });
41
- if (config)
42
- this.options.assign(config);
43
43
  this._factory = factory;
44
44
  }
45
45
  /**
@@ -436,25 +436,25 @@ export class Pool extends EventEmitter {
436
436
  _itemDestroy(item, callback) {
437
437
  this._itemDetach(item);
438
438
  const handleCallback = (err) => {
439
- if (err) {
440
- this.emit('destroy-error', err, item.resource);
441
- /* istanbul ignore next */
442
- return callback && callback(err);
443
- }
444
- this.emit('destroy', item.resource);
445
439
  item.destroyed = true;
440
+ this._allResources.delete(item.resource);
441
+ if (err)
442
+ this.emit('destroy-error', err, item.resource);
443
+ else
444
+ this.emit('destroy', item.resource);
446
445
  if (callback)
447
- callback();
446
+ callback(err);
448
447
  };
449
448
  try {
450
- this._allResources.delete(item.resource);
451
- this._processNextRequest();
452
449
  const o = this._factory.destroy(item.resource);
453
450
  promisify.await(o, handleCallback);
454
451
  }
455
452
  catch (e) {
456
453
  handleCallback(e);
457
454
  }
455
+ finally {
456
+ this._processNextRequest();
457
+ }
458
458
  }
459
459
  _itemValidate(item, callback) {
460
460
  item.state = ResourceState.VALIDATION;
@@ -0,0 +1 @@
1
+ {"root":["../../src/abort-error.ts","../../src/definitions.ts","../../src/index.ts","../../src/pool-options.ts","../../src/pool-request.ts","../../src/pool.ts","../../src/resource-item.ts"],"version":"5.6.3"}
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "lightning-pool",
3
3
  "description": "Fastest generic Pool written with TypeScript",
4
- "version": "4.8.0",
5
- "author": "Panates Ltd.",
4
+ "version": "4.10.0",
5
+ "author": "Panates",
6
6
  "license": "MIT",
7
- "repository": "panates/lightning-pool",
8
7
  "dependencies": {
9
8
  "doublylinked": "^2.5.4",
10
9
  "putil-promisify": "^1.10.1",
11
- "tslib": "^2.6.3"
10
+ "tslib": "^2.8.0"
12
11
  },
13
12
  "type": "module",
14
13
  "exports": {
@@ -28,6 +27,10 @@
28
27
  "main": "./cjs/index.js",
29
28
  "module": "./esm/index.js",
30
29
  "types": "./types/index.d.ts",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/panates/lightning-pool.git"
33
+ },
31
34
  "contributors": [
32
35
  "Eray Hanoglu <e.hanoglu@panates.com>"
33
36
  ],