@lwrjs/shared-utils 0.8.0-alpha.1 → 0.8.0-alpha.2

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.
@@ -58,15 +58,12 @@ var InflightTasks = class {
58
58
  constructor() {
59
59
  this.tasks = new Map();
60
60
  }
61
- execute(id, taskCtor, caller) {
62
- if (this.tasks.has(id)) {
63
- return this.tasks.get(id);
64
- } else {
65
- const job = taskCtor.bind(caller || this)().finally(() => {
66
- this.tasks.delete(id);
67
- });
68
- this.tasks.set(id, job);
69
- return job;
61
+ execute(id, fn) {
62
+ let promise = this.tasks.get(id);
63
+ if (!promise) {
64
+ promise = fn().finally(() => this.tasks.delete(id));
65
+ this.tasks.set(id, promise);
70
66
  }
67
+ return promise;
71
68
  }
72
69
  };
@@ -23,16 +23,15 @@ export declare class TaskPool {
23
23
  * Calls to execute with the id of a task in progress returns the running tasks
24
24
  * If no task of that id is running a new task is created
25
25
  */
26
- export declare class InflightTasks<Type> {
26
+ export declare class InflightTasks<Value> {
27
27
  private tasks;
28
28
  /**
29
29
  * Return a promise per id. If one is already in flight return the promise.
30
30
  * If not use the constructor to create a new
31
31
  *
32
32
  * @param id - Unique id for promise in question
33
- * @param taskCtor - Function that create a promise for the id if needed
34
- * @param caller - The closer to use when calling the constructor
33
+ * @param fn - Function that create a promise for the id if needed
35
34
  */
36
- execute(id: string, taskCtor: Function, caller?: any): Promise<Type>;
35
+ execute(id: string, fn: () => Promise<Value>): Promise<Value>;
37
36
  }
38
37
  //# sourceMappingURL=tasks.d.ts.map
package/build/es/tasks.js CHANGED
@@ -75,24 +75,15 @@ export class InflightTasks {
75
75
  * If not use the constructor to create a new
76
76
  *
77
77
  * @param id - Unique id for promise in question
78
- * @param taskCtor - Function that create a promise for the id if needed
79
- * @param caller - The closer to use when calling the constructor
78
+ * @param fn - Function that create a promise for the id if needed
80
79
  */
81
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
82
- execute(id, taskCtor, caller) {
83
- if (this.tasks.has(id)) {
84
- return this.tasks.get(id);
85
- }
86
- else {
87
- const job = taskCtor
88
- .bind(caller || this)()
89
- .finally(() => {
90
- // Once fulfilled remove form active jobs
91
- this.tasks.delete(id);
92
- });
93
- this.tasks.set(id, job);
94
- return job;
80
+ execute(id, fn) {
81
+ let promise = this.tasks.get(id);
82
+ if (!promise) {
83
+ promise = fn().finally(() => this.tasks.delete(id));
84
+ this.tasks.set(id, promise);
95
85
  }
86
+ return promise;
96
87
  }
97
88
  }
98
89
  //# sourceMappingURL=tasks.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.8.0-alpha.1",
7
+ "version": "0.8.0-alpha.2",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -40,17 +40,18 @@
40
40
  "magic-string": "^0.25.7",
41
41
  "mime-types": "^2.1.33",
42
42
  "parse5-sax-parser": "^6.0.1",
43
+ "path-to-regexp": "^6.2.0",
43
44
  "slugify": "^1.4.5",
44
45
  "winston": "^3.7.2"
45
46
  },
46
47
  "devDependencies": {
47
- "@lwrjs/diagnostics": "0.8.0-alpha.1",
48
- "@lwrjs/types": "0.8.0-alpha.1",
48
+ "@lwrjs/diagnostics": "0.8.0-alpha.2",
49
+ "@lwrjs/types": "0.8.0-alpha.2",
49
50
  "@types/mime-types": "2.1.1",
50
51
  "@types/path-to-regexp": "^1.7.0"
51
52
  },
52
53
  "engines": {
53
54
  "node": ">=14.15.4 <19"
54
55
  },
55
- "gitHead": "2718cc5abe11d0d6fd5375cf9205167b6f69e244"
56
+ "gitHead": "44bee038acb30418870678d886e3ded4a6afecf0"
56
57
  }