monocart-reporter 2.9.6 → 2.9.8
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/LICENSE +21 -21
- package/README.md +1180 -1180
- package/lib/cli.js +372 -372
- package/lib/common.js +244 -244
- package/lib/default/columns.js +79 -79
- package/lib/default/options.js +95 -95
- package/lib/default/summary.js +80 -80
- package/lib/default/template.html +47 -47
- package/lib/generate-data.js +174 -174
- package/lib/generate-report.js +360 -360
- package/lib/index.d.ts +268 -268
- package/lib/index.js +253 -253
- package/lib/index.mjs +19 -19
- package/lib/merge-data.js +405 -405
- package/lib/packages/monocart-reporter-assets.js +3 -3
- package/lib/packages/monocart-reporter-vendor.js +22 -23
- package/lib/platform/concurrency.js +74 -74
- package/lib/platform/share.js +369 -369
- package/lib/plugins/audit/audit.js +119 -119
- package/lib/plugins/comments.js +124 -124
- package/lib/plugins/coverage/coverage.js +169 -169
- package/lib/plugins/email.js +76 -76
- package/lib/plugins/metadata/metadata.js +25 -25
- package/lib/plugins/network/network.js +186 -186
- package/lib/plugins/state/client.js +152 -152
- package/lib/plugins/state/state.js +194 -194
- package/lib/utils/pie.js +148 -148
- package/lib/utils/system.js +145 -145
- package/lib/utils/util.js +512 -511
- package/lib/visitor.js +915 -915
- package/package.json +10 -10
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
class Concurrency {
|
|
2
|
-
|
|
3
|
-
constructor(maxCount = 10) {
|
|
4
|
-
this.maxCount = maxCount;
|
|
5
|
-
this.list = [];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
addItem(item) {
|
|
9
|
-
this.list.push(item);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
addList(list) {
|
|
13
|
-
this.list = this.list.concat(list);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
start(handler) {
|
|
17
|
-
// must be async function
|
|
18
|
-
if (typeof handler !== 'function') {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.handler = handler;
|
|
22
|
-
this.count = 0;
|
|
23
|
-
return new Promise((resolve) => {
|
|
24
|
-
this.resolve = resolve;
|
|
25
|
-
this.next();
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
next() {
|
|
30
|
-
// console.log(`list: ${this.list.length} count: ${this.count}`);
|
|
31
|
-
|
|
32
|
-
// if has clear
|
|
33
|
-
if (!this.resolve) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!this.list.length) {
|
|
38
|
-
// no list but has in progress count
|
|
39
|
-
if (this.count > 0) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
// all finish
|
|
43
|
-
this.resolve();
|
|
44
|
-
this.clear();
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// out of concurrency count, just wait
|
|
49
|
-
if (this.count >= this.maxCount) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const item = this.list.shift();
|
|
54
|
-
this.count += 1;
|
|
55
|
-
|
|
56
|
-
// async handler
|
|
57
|
-
this.handler(item).finally(() => {
|
|
58
|
-
this.count -= 1;
|
|
59
|
-
this.next();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
this.next();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
clear() {
|
|
66
|
-
this.list = [];
|
|
67
|
-
this.handler = null;
|
|
68
|
-
this.count = 0;
|
|
69
|
-
this.resolve = null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = Concurrency;
|
|
1
|
+
class Concurrency {
|
|
2
|
+
|
|
3
|
+
constructor(maxCount = 10) {
|
|
4
|
+
this.maxCount = maxCount;
|
|
5
|
+
this.list = [];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
addItem(item) {
|
|
9
|
+
this.list.push(item);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
addList(list) {
|
|
13
|
+
this.list = this.list.concat(list);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
start(handler) {
|
|
17
|
+
// must be async function
|
|
18
|
+
if (typeof handler !== 'function') {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.handler = handler;
|
|
22
|
+
this.count = 0;
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
this.resolve = resolve;
|
|
25
|
+
this.next();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
next() {
|
|
30
|
+
// console.log(`list: ${this.list.length} count: ${this.count}`);
|
|
31
|
+
|
|
32
|
+
// if has clear
|
|
33
|
+
if (!this.resolve) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!this.list.length) {
|
|
38
|
+
// no list but has in progress count
|
|
39
|
+
if (this.count > 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// all finish
|
|
43
|
+
this.resolve();
|
|
44
|
+
this.clear();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// out of concurrency count, just wait
|
|
49
|
+
if (this.count >= this.maxCount) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const item = this.list.shift();
|
|
54
|
+
this.count += 1;
|
|
55
|
+
|
|
56
|
+
// async handler
|
|
57
|
+
this.handler(item).finally(() => {
|
|
58
|
+
this.count -= 1;
|
|
59
|
+
this.next();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this.next();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
clear() {
|
|
66
|
+
this.list = [];
|
|
67
|
+
this.handler = null;
|
|
68
|
+
this.count = 0;
|
|
69
|
+
this.resolve = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = Concurrency;
|