mock-service-cli 4.0.0 → 4.1.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.
- package/dist/asyncTaskQueue.js +1 -62
- package/dist/cli.js +1 -6608
- package/dist/fileExplorerServer.js +1 -28186
- package/dist/manageMockFiles.js +1 -5020
- package/dist/mockServer.js +1 -53214
- package/dist/packageInfo.js +1 -19
- package/dist/runtime.js +144 -0
- package/dist/staticServer.js +1 -26688
- package/dist/utils.js +1 -857
- package/package.json +12 -12
package/dist/asyncTaskQueue.js
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var AsyncTaskQueue = class {
|
|
3
|
-
constructor(isSaveItem = false) {
|
|
4
|
-
this.list = [];
|
|
5
|
-
this.index = 0;
|
|
6
|
-
this.isStop = false;
|
|
7
|
-
this.isParallel = false;
|
|
8
|
-
this.isSaveItem = isSaveItem;
|
|
9
|
-
}
|
|
10
|
-
next() {
|
|
11
|
-
if (this.index >= this.list.length - 1 || this.isStop) return;
|
|
12
|
-
if (!this.isSaveItem) {
|
|
13
|
-
this.list.splice(this.index, 1, "");
|
|
14
|
-
}
|
|
15
|
-
const cur = this.list[++this.index];
|
|
16
|
-
cur(this.next.bind(this));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @description: 增加异步任务
|
|
20
|
-
* @param {array} fn
|
|
21
|
-
*/
|
|
22
|
-
add(...fn) {
|
|
23
|
-
this.list.push(...fn);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* @description: 按序执行异步任务
|
|
27
|
-
*/
|
|
28
|
-
run() {
|
|
29
|
-
const cur = this.list[this.index];
|
|
30
|
-
typeof cur === "function" && cur(this.next.bind(this));
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @description: 并发执行异步任务
|
|
34
|
-
*/
|
|
35
|
-
parallelRun() {
|
|
36
|
-
this.isParallel = true;
|
|
37
|
-
for (const fn of this.list) {
|
|
38
|
-
fn(this.next.bind(this));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @description: 暂停执行异步任务
|
|
43
|
-
*/
|
|
44
|
-
stop() {
|
|
45
|
-
this.isStop = true;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @description: 重试执行异步任务
|
|
49
|
-
*/
|
|
50
|
-
retry() {
|
|
51
|
-
this.isStop = false;
|
|
52
|
-
this.run();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @description: 继续执行下一个异步任务
|
|
56
|
-
*/
|
|
57
|
-
goOn() {
|
|
58
|
-
this.isStop = false;
|
|
59
|
-
this.next();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
module.exports = AsyncTaskQueue;
|
|
1
|
+
module.exports = require('./runtime').load('asyncTaskQueue');
|