Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a23b4f

Browse files
committed
feat: add jest && change README.md
1 parenta0bd6d3 commit9a23b4f

15 files changed

+554
-1157
lines changed

‎.babelrc‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{
2-
"presets": [
3-
"@babel/preset-typescript",
4-
[
5-
"@babel/preset-env",
6-
{
7-
8-
"modules":false
9-
}
10-
]
11-
]
12-
// "presets": ["@babel/preset-env", {"targets": {"node": "current"}}]
2+
"presets": ["@babel/preset-env"]
133
}
144

‎.gitignore‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
node_modules
22
.DS_Store
33
examples/
4-
test/
54
dist
6-
demo
7-
taskOrder.test.js
5+
demo

‎README-zh_CN.md‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ const asyncTask = createTaskList({
3030

3131
setTimeout(async ()=> {
3232
// 这里返回一个Promise.resolve,你可以使用async/await或者.then.
33-
constdata=await asyncTask;
34-
console.log("data-1",data);
33+
const{list,dataMap }=await asyncTask;
34+
console.log("data-1",list[0]);
3535
// 或者
36-
asyncTask.then((data)=> {
37-
console.log("data-1",data);
36+
asyncTask.then(({ list, dataMap })=> {
37+
console.log("data-1",list[0]);
3838
});
3939
},100);
4040

4141
setTimeout(async ()=> {
42-
constdata=await asyncTask;
43-
console.log("data-2",data);
42+
const{list,dataMap }=await asyncTask;
43+
console.log("data-2",dataMap.res2);
4444
},200);
4545

4646
setTimeout(()=> {
4747
asyncTask.pushResolve("response1");
4848
},300);
4949

5050
setTimeout(()=> {
51-
asyncTask.pushResolve("response2");
51+
asyncTask.pushResolve("response2","res2");
5252
},400);
5353
```
5454

@@ -70,13 +70,14 @@ setTimeout(() => {
7070

7171
####createTaskList 实例上的方法
7272

73-
| 名称| 描述| 返回值的数据结构|
74-
| -----------| --------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75-
| pushResolve| 增加数据的方法| --|
76-
| clear| 清空所有的状态| --|
77-
| paused| 暂停任务| --|
78-
| running| 继续匹配任务| --|
79-
| getStatus| 获取当前状态| {<br>&nbsp;&nbsp; requestDone: false (是否完成所有的 request 绑定), <br>&nbsp;&nbsp; responseDone: false (是否完成所有的 pushResolve), <br>&nbsp;&nbsp; requestCount: 1 (已绑定的 request 数量),<br>&nbsp;&nbsp; responseCount: 1 (已完成的 pushResolve 数量)<br>}|
73+
| 名称| 描述| 返回值的数据结构|
74+
| -----------| --------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75+
| then\*| promise 上原有的方法| task.then(({list, dataMap})=>{})|
76+
| pushResolve| 增加数据的方法| pushResolve(data, name), 非必填,Promise.resolve 的数据|
77+
| clear| 清空所有的状态| --|
78+
| paused| 暂停任务| --|
79+
| running| 继续匹配任务| --|
80+
| getStatus| 获取当前状态| {<br>&nbsp;&nbsp; requestDone: false (是否完成所有的 request 绑定), <br>&nbsp;&nbsp; responseDone: false (是否完成所有的 pushResolve), <br>&nbsp;&nbsp; requestCount: 1 (已绑定的 request 数量),<br>&nbsp;&nbsp; responseCount: 1 (已完成的 pushResolve 数量)<br>}|
8081

8182
###使用 createTaskOrder
8283

‎README.md‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ const asyncTask = createTaskList({
3030

3131
setTimeout(async ()=> {
3232
// A Promise.resolve is returned here. You can use either async/await or .then.
33-
constdata=await asyncTask;
34-
console.log("data-1",data);
33+
const{list,dataMap }=await asyncTask;
34+
console.log("data-1",list[0]);
3535
// or
36-
asyncTask.then((data)=> {
37-
console.log("data-1",data);
36+
asyncTask.then(({ list, dataMap })=> {
37+
console.log("data-1",list[0]);
3838
});
3939
},100);
4040

4141
setTimeout(async ()=> {
42-
constdata=await asyncTask;
43-
console.log("data-2",data);
42+
const{list,dataMap }=await asyncTask;
43+
console.log("data-2",dataMap.res2);
4444
},200);
4545

4646
setTimeout(()=> {
4747
asyncTask.pushResolve("response1");
4848
},300);
4949

5050
setTimeout(()=> {
51-
asyncTask.pushResolve("response2");
51+
asyncTask.pushResolve("response2","res2");
5252
},400);
5353
```
5454

@@ -70,13 +70,14 @@ You can use these functions in different methods. The result of the above code i
7070

7171
####Methods on createTaskList Instances
7272

73-
| name| description| returned data structure|
74-
| -----------| -----------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75-
| pushResolve| Used to add data| --|
76-
| clear| Clear all statuses| --|
77-
| paused| pause task| --|
78-
| running| continue matching tasks| --|
79-
| getStatus| Get current status| {<br>&nbsp;&nbsp;// Whether to complete all request binding <br>&nbsp;&nbsp; requestDone: false, <br>&nbsp;&nbsp;// Whether to complete all pushResolve<br>&nbsp;&nbsp; responseDone: false, <br>&nbsp;&nbsp; //Number of requests bound <br>&nbsp;&nbsp; requestCount: 1 (Number of requests bound), <br>&nbsp;&nbsp; // Number of pushResolve complete<br>&nbsp;&nbsp;responseCount: 1 (Number of pushResolve completed)<br>}|
73+
| name| description| returned data structure|
74+
| -----------| ------------------------------| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
75+
| then\*| The original method of promise| task.then(({list, dataMap})=>{})|
76+
| pushResolve| Used to add data| pushResolve(data, name), Not required, data of Promise.resolve|
77+
| clear| Clear all statuses| --|
78+
| paused| pause task| --|
79+
| running| continue matching tasks| --|
80+
| getStatus| Get current status| {<br>&nbsp;&nbsp;// Whether to complete all request binding <br>&nbsp;&nbsp; requestDone: false, <br>&nbsp;&nbsp;// Whether to complete all pushResolve<br>&nbsp;&nbsp; responseDone: false, <br>&nbsp;&nbsp; //Number of requests bound <br>&nbsp;&nbsp; requestCount: 1 (Number of requests bound), <br>&nbsp;&nbsp; // Number of pushResolve complete<br>&nbsp;&nbsp;responseCount: 1 (Number of pushResolve completed)<br>}|
8081

8182
###use createTaskOrder
8283

‎babel.config.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
module.exports={
2-
presets:[['@babel/preset-env',{targets:{node:'current'}}]],
3-
};
2+
// presets: [["@babel/preset-env", { targets: { node: "current" }}]],
3+
env:{
4+
test:{
5+
plugins:["@babel/plugin-transform-runtime"],
6+
},
7+
},
8+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp