@lwrjs/shared-utils 0.8.0-alpha.0 → 0.8.0-alpha.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.
- package/build/cjs/tasks.cjs +6 -9
- package/build/es/tasks.d.ts +3 -4
- package/build/es/tasks.js +7 -16
- package/package.json +5 -4
package/build/cjs/tasks.cjs
CHANGED
|
@@ -58,15 +58,12 @@ var InflightTasks = class {
|
|
|
58
58
|
constructor() {
|
|
59
59
|
this.tasks = new Map();
|
|
60
60
|
}
|
|
61
|
-
execute(id,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
};
|
package/build/es/tasks.d.ts
CHANGED
|
@@ -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<
|
|
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
|
|
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,
|
|
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
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
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.
|
|
7
|
+
"version": "0.8.0-alpha.3",
|
|
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.
|
|
48
|
-
"@lwrjs/types": "0.8.0-alpha.
|
|
48
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.3",
|
|
49
|
+
"@lwrjs/types": "0.8.0-alpha.3",
|
|
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": "
|
|
56
|
+
"gitHead": "bf22045bd29a832ff98f6bafa1120b5453960f8c"
|
|
56
57
|
}
|