lightning-pool 4.1.0 → 4.2.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.
File without changes
package/cjs/index.js CHANGED
@@ -15,11 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.createPool = void 0;
18
- const Pool_js_1 = require("./Pool.js");
18
+ const pool_js_1 = require("./pool.js");
19
19
  __exportStar(require("./definitions.js"), exports);
20
- __exportStar(require("./Pool.js"), exports);
21
- __exportStar(require("./AbortError.js"), exports);
20
+ __exportStar(require("./pool.js"), exports);
21
+ __exportStar(require("./abort-error.js"), exports);
22
22
  function createPool(factory, config) {
23
- return new Pool_js_1.Pool(factory, config);
23
+ return new pool_js_1.Pool(factory, config);
24
24
  }
25
25
  exports.createPool = createPool;
File without changes
File without changes
@@ -7,11 +7,11 @@ exports.Pool = void 0;
7
7
  const doublylinked_1 = __importDefault(require("doublylinked"));
8
8
  const events_1 = require("events");
9
9
  const putil_promisify_1 = __importDefault(require("putil-promisify"));
10
- const AbortError_js_1 = require("./AbortError.js");
10
+ const abort_error_js_1 = require("./abort-error.js");
11
11
  const definitions_js_1 = require("./definitions.js");
12
- const PoolOptions_js_1 = require("./PoolOptions.js");
13
- const PoolRequest_js_1 = require("./PoolRequest.js");
14
- const ResourceItem_js_1 = require("./ResourceItem.js");
12
+ const pool_options_js_1 = require("./pool-options.js");
13
+ const pool_request_js_1 = require("./pool-request.js");
14
+ const resource_item_js_1 = require("./resource-item.js");
15
15
  class Pool extends events_1.EventEmitter {
16
16
  constructor(factory, config) {
17
17
  super();
@@ -32,7 +32,7 @@ class Pool extends events_1.EventEmitter {
32
32
  throw new TypeError('factory.validate can be a function');
33
33
  if (factory.reset && typeof factory.reset !== 'function')
34
34
  throw new TypeError('factory.reset can be a function');
35
- const opts = this._options = new PoolOptions_js_1.PoolOptions(this);
35
+ const opts = this._options = new pool_options_js_1.PoolOptions(this);
36
36
  opts.on('change', (prop, val) => {
37
37
  if (prop === 'houseKeepInterval')
38
38
  this._setHouseKeep(val);
@@ -162,7 +162,7 @@ class Pool extends events_1.EventEmitter {
162
162
  }
163
163
  if (this.options.maxQueue && this.pending >= this.options.maxQueue)
164
164
  return callback(new Error('Pool queue is full'));
165
- this._requestQueue.push(new PoolRequest_js_1.PoolRequest(this, callback));
165
+ this._requestQueue.push(new pool_request_js_1.PoolRequest(this, callback));
166
166
  this._processNextRequest();
167
167
  }
168
168
  /**
@@ -294,7 +294,7 @@ class Pool extends events_1.EventEmitter {
294
294
  tries,
295
295
  maxRetries: this.options.acquireMaxRetries
296
296
  });
297
- if (err instanceof AbortError_js_1.AbortError || tries >= maxRetries) {
297
+ if (err instanceof abort_error_js_1.AbortError || tries >= maxRetries) {
298
298
  this._creating--;
299
299
  return callback && callback(err);
300
300
  }
@@ -304,7 +304,7 @@ class Pool extends events_1.EventEmitter {
304
304
  if (this._allResources.has(obj))
305
305
  return callback &&
306
306
  callback(new Error('Factory error. Resource already in pool'));
307
- const item = new ResourceItem_js_1.ResourceItem(obj);
307
+ const item = new resource_item_js_1.ResourceItem(obj);
308
308
  this._itemSetIdle(item);
309
309
  this._allResources.set(obj, item);
310
310
  if (callback)
@@ -316,7 +316,7 @@ class Pool extends events_1.EventEmitter {
316
316
  const o = this._factory.create({ tries, maxRetries });
317
317
  /* istanbul ignore next */
318
318
  if (!o)
319
- return handleCallback(new AbortError_js_1.AbortError('Factory returned no resource'));
319
+ return handleCallback(new abort_error_js_1.AbortError('Factory returned no resource'));
320
320
  putil_promisify_1.default.await(o, handleCallback);
321
321
  }
322
322
  catch (e) {
File without changes
File without changes
File without changes
package/esm/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PoolConfiguration, PoolFactory } from './definitions.js';
2
- import { Pool } from './Pool.js';
2
+ import { Pool } from './pool.js';
3
3
  export * from './definitions.js';
4
- export * from './Pool.js';
5
- export * from './AbortError.js';
4
+ export * from './pool.js';
5
+ export * from './abort-error.js';
6
6
  export declare function createPool<T = any>(factory: PoolFactory<T>, config?: PoolConfiguration): Pool<T>;
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Pool } from './Pool.js';
1
+ import { Pool } from './pool.js';
2
2
  export * from './definitions.js';
3
- export * from './Pool.js';
4
- export * from './AbortError.js';
3
+ export * from './pool.js';
4
+ export * from './abort-error.js';
5
5
  export function createPool(factory, config) {
6
6
  return new Pool(factory, config);
7
7
  }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import { PoolConfiguration } from './definitions.js';
4
- import { Pool } from './Pool.js';
4
+ import { Pool } from './pool.js';
5
5
  export declare class PoolOptions extends EventEmitter {
6
6
  readonly pool: Pool;
7
7
  private _acquireMaxRetries;
File without changes
@@ -1,5 +1,5 @@
1
1
  import { Callback } from './definitions.js';
2
- import { Pool } from './Pool.js';
2
+ import { Pool } from './pool.js';
3
3
  export declare class PoolRequest {
4
4
  created: number;
5
5
  callback: Callback;
File without changes
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import { Callback, PoolConfiguration, PoolFactory, PoolState } from './definitions.js';
4
- import { PoolOptions } from './PoolOptions.js';
4
+ import { PoolOptions } from './pool-options.js';
5
5
  export declare class Pool<T = any> extends EventEmitter {
6
6
  private readonly _options;
7
7
  private readonly _factory;
@@ -66,7 +66,7 @@ export declare class Pool<T = any> extends EventEmitter {
66
66
  /**
67
67
  * Releases an allocated `resource` and let it back to pool.
68
68
  */
69
- release(resource: T, callback?: Callback): any;
69
+ release(resource: T, callback?: Callback): void;
70
70
  /**
71
71
  * Async version of release().
72
72
  */
@@ -1,11 +1,11 @@
1
1
  import DoublyLinked from 'doublylinked';
2
2
  import { EventEmitter } from 'events';
3
3
  import promisify from 'putil-promisify';
4
- import { AbortError } from './AbortError.js';
4
+ import { AbortError } from './abort-error.js';
5
5
  import { PoolState, ResourceState } from './definitions.js';
6
- import { PoolOptions } from './PoolOptions.js';
7
- import { PoolRequest } from './PoolRequest.js';
8
- import { ResourceItem } from './ResourceItem.js';
6
+ import { PoolOptions } from './pool-options.js';
7
+ import { PoolRequest } from './pool-request.js';
8
+ import { ResourceItem } from './resource-item.js';
9
9
  export class Pool extends EventEmitter {
10
10
  constructor(factory, config) {
11
11
  super();
File without changes
File without changes
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.1.0",
4
+ "version": "4.2.0",
5
5
  "author": "Panates Ltd.",
6
6
  "contributors": [
7
7
  "Eray Hanoglu <e.hanoglu@panates.com>"
@@ -19,25 +19,25 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "@babel/eslint-parser": "^7.19.1",
22
- "@types/jest": "^29.0.3",
23
- "@types/node": "^18.7.18",
24
- "@typescript-eslint/eslint-plugin": "^5.38.0",
25
- "@typescript-eslint/parser": "^5.38.0",
26
- "dotenv": "^16.0.2",
27
- "eslint": "^8.23.1",
22
+ "@types/jest": "^29.1.2",
23
+ "@types/node": "^18.8.5",
24
+ "@typescript-eslint/eslint-plugin": "^5.40.0",
25
+ "@typescript-eslint/parser": "^5.40.0",
26
+ "dotenv": "^16.0.3",
27
+ "eslint": "^8.25.0",
28
28
  "eslint-config-google": "^0.14.0",
29
29
  "eslint-plugin-import": "^2.26.0",
30
30
  "eslint-plugin-security": "^1.5.0",
31
31
  "eslint-plugin-simple-import-sort": "^8.0.0",
32
32
  "eslint-plugin-unused-imports": "^2.0.0",
33
- "jest": "^29.0.3",
33
+ "jest": "^29.2.0",
34
34
  "npm-run-path": "^5.1.0",
35
35
  "ts-cleanup": "^0.2.5",
36
- "ts-jest": "^29.0.1",
36
+ "ts-jest": "^29.0.3",
37
37
  "ts-loader": "^9.4.1",
38
38
  "ts-node": "^10.9.1",
39
39
  "tsconfig-paths": "^4.1.0",
40
- "typescript": "^4.8.3"
40
+ "typescript": "^4.8.4"
41
41
  },
42
42
  "type": "module",
43
43
  "types": "esm/index.d.ts",