better-lock 2.0.0-beta → 2.0.3

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.
Files changed (36) hide show
  1. package/.idea/markdown.xml +9 -0
  2. package/README.md +51 -53
  3. package/dist/better_lock.d.ts +7 -4
  4. package/dist/better_lock.js +4 -1
  5. package/dist/better_lock.js.map +1 -1
  6. package/dist/errors.js +3 -1
  7. package/dist/errors.js.map +1 -1
  8. package/docs/.nojekyll +1 -0
  9. package/docs/assets/highlight.css +92 -0
  10. package/docs/assets/icons.css +1043 -0
  11. package/docs/assets/icons.png +0 -0
  12. package/docs/assets/icons@2x.png +0 -0
  13. package/docs/assets/main.js +52 -0
  14. package/docs/assets/search.js +1 -0
  15. package/docs/assets/style.css +1414 -0
  16. package/docs/assets/widgets.png +0 -0
  17. package/docs/assets/widgets@2x.png +0 -0
  18. package/docs/classes/BetterLockError.html +5 -0
  19. package/docs/classes/BetterLockExecutionTimeoutError.html +5 -0
  20. package/docs/classes/BetterLockInternalError.html +5 -0
  21. package/docs/classes/BetterLockInvalidArgumentError.html +5 -0
  22. package/docs/classes/BetterLockJobAbortedError.html +5 -0
  23. package/docs/classes/BetterLockQueueOverflowError.html +5 -0
  24. package/docs/classes/BetterLockWaitTimeoutError.html +5 -0
  25. package/docs/classes/_internal_.BetterLock.html +92 -0
  26. package/docs/classes/_internal_.KeyQueue.html +8 -0
  27. package/docs/classes/_internal_.LockJob.html +28 -0
  28. package/docs/index.html +211 -0
  29. package/docs/interfaces/BetterLockJobOptions.html +9 -0
  30. package/docs/interfaces/BetterLockOptions.html +21 -0
  31. package/docs/modules/_internal_.__home_panta_dev_pantas_better_lock_src_errors_.html +1 -0
  32. package/docs/modules/_internal_.html +7 -0
  33. package/docs/modules.html +5 -0
  34. package/package.json +10 -6
  35. package/src/better_lock.ts +7 -4
  36. package/src/errors.ts +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-lock",
3
- "version": "2.0.0-beta",
3
+ "version": "2.0.3",
4
4
  "description": "A (better) node.js lock library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "test": "jest",
11
11
  "watch": "jest --watchAll",
12
12
  "lint": "eslint ./src",
13
- "coverage": "jest --coverage"
13
+ "coverage": "jest --coverage",
14
+ "docs": "typedoc src/index.ts --excludePrivate --excludeProtected --excludeExternals"
14
15
  },
15
16
  "repository": {
16
17
  "type": "git",
@@ -26,16 +27,18 @@
26
27
  "sync"
27
28
  ],
28
29
  "devDependencies": {
29
- "@types/jest": "^26.0.23",
30
+ "@types/jest": "^27.5.1",
30
31
  "@typescript-eslint/eslint-plugin": "^4.25.0",
31
32
  "@typescript-eslint/parser": "^4.25.0",
32
33
  "eslint": "^7.27.0",
33
34
  "eslint-config-prettier": "^8.3.0",
34
35
  "import-sort-style-module": "^6.0.0",
35
- "jest": "^27.0.2",
36
+ "jest": "^28.1.0",
36
37
  "prettier": "latest",
37
38
  "prettier-plugin-import-sort": "0.0.7",
38
- "ts-jest": "^27.0.1",
39
+ "ts-jest": "^28.0.3",
40
+ "typedoc": "^0.22.15",
41
+ "typedoc-plugin-missing-exports": "^0.22.6",
39
42
  "typescript": "^4.3.2"
40
43
  },
41
44
  "author": "Ivan Pantic",
@@ -52,5 +55,6 @@
52
55
  ".js, .jsx": {
53
56
  "style": "module"
54
57
  }
55
- }
58
+ },
59
+ "dependencies": {}
56
60
  }
@@ -12,7 +12,7 @@ import * as tools from './tools';
12
12
  import { ICallback, ICallbackExecutor, ILockKey, IPromiseExecutor } from './types';
13
13
 
14
14
  /**
15
- * Create a better lock object.
15
+ * Main better lock class.
16
16
  */
17
17
  export class BetterLock {
18
18
  /**
@@ -23,10 +23,13 @@ export class BetterLock {
23
23
  promise_tester: p => p && typeof p.then === 'function',
24
24
  };
25
25
 
26
- private options: IOptions;
27
- private log: (msg: string) => void;
28
- private queues: { [key: string]: KeyQueue };
26
+ private readonly options: IOptions;
27
+ private readonly log: (msg: string) => void;
28
+ private readonly queues: { [key: string]: KeyQueue };
29
29
 
30
+ /**
31
+ * Create a better lock instance
32
+ */
30
33
  constructor(options?: IOptions) {
31
34
  this.options = tools.assign({}, [BetterLock.DEFAULT_OPTIONS, options]);
32
35
  this.log = tools.makeLog(this.options.name, this.options.log);
package/src/errors.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LockJob } from './internals';
1
+ import { KeyQueue, LockJob } from './internals';
2
2
  import { IErrorName } from './types';
3
3
 
4
4
  export class BetterLockError extends Error {
@@ -99,7 +99,8 @@ export class BetterLockQueueOverflowError extends BetterLockError {
99
99
  public kicked_out_job_id: number;
100
100
 
101
101
  constructor(lockName, key, count, job: LockJob<any>) {
102
- const message = `Too many jobs (${count}) waiting for ${key}. The most recent job (${job}) was kicked out`;
102
+ const keyDesignation = key === KeyQueue.DEFAULT_QUEUE_KEY ? '' : ` for key "${key}"`;
103
+ const message = `Too many jobs (${count}) are waiting${keyDesignation}. The most recent job (${job}) was kicked out`;
103
104
 
104
105
  super(lockName, message, job.incoming_stack);
105
106