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

Commit9d49f3a

Browse files
committed
add jest && change name
1 parent4932dae commit9d49f3a

File tree

10 files changed

+74
-11
lines changed

10 files changed

+74
-11
lines changed

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
node_modules
22
.DS_Store
33
examples/
4-
test/
54
dist
65
demo
76
taskOrder.test.js

‎README-zh_CN.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const asyncTask = createTaskList({ordered: true, requestCount: 2, responseCount:
5959
| request| 接收的方法,可以传入一个立即执行的函数| Promise类型, 如果responseCount为1,<br>得到的data是pushResponse的原数据,<br> 如果responseCount大于1,将得到一个数组|
6060
| pushResponse| 增加数据的方法| --|
6161
| clear| 清空所有的状态| --|
62+
| paused (v0.1.0)| 暂停任务| --|
63+
| running (v0.1.0)| 继续匹配任务| --|
6264
| getStatus| 获取当前状态| {<br>&nbsp;&nbsp; requestDone: false (是否完成所有的request绑定), <br>&nbsp;&nbsp; responseDone: false (是否完成所有的pushResponse), <br>&nbsp;&nbsp; requestCount: 1 (已绑定的request数量),<br>&nbsp;&nbsp; responseCount: 1 (已完成的pushResponse数量)<br>}|
6365

6466

@@ -103,8 +105,10 @@ const taskOrder = createTaskOrder()
103105
| request| 接收数据的方法,可以传入一个立即执行的函数| Promise类型, 得到的data是pushResponse的原数据|
104106
| pushResponse| 增加数据的方法| --|
105107
| clear| 清空所有的状态| --|
108+
| paused (v0.1.0)| 暂停任务| --|
109+
| running (v0.1.0)| 继续匹配任务| --|
106110
| getStatus| 获取当前状态| {<br>&nbsp;&nbsp; pendingRequests: 0 (未完成匹配的request数量), <br>&nbsp;&nbsp; pendingResponses: 0 (未完成匹配的response数量)<br>}|
107-
| getLastCompletedTask| 获取最后一个request与response完成匹配的数据| --|
111+
| getLastCompletedTask<br>(v0.1.0)| 获取最后一个request与response完成匹配的数据| --|
108112

109113

110114
###开源协议

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ You can use these functions in different methods. The result of the above code i
5959
| request| Used to access data| Promise type, The data obtained is the original data of <br> pushResponse. If the responseCount is greater than 1,<br> an array will be obtained|
6060
| pushResponse| Used to add data| --|
6161
| clear| Clear all statuses| --|
62+
| paused (v0.1.0)| pause task| --|
63+
| running (v0.1.0)| continue matching tasks| --|
6264
| 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 pushResponse<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 pushResponse complete<br>&nbsp;&nbsp;responseCount: 1 (Number of pushResponse completed)<br>}|
6365

6466
###use createTaskOrder
@@ -100,6 +102,8 @@ You can use these functions in different methods. The result of the above code i
100102
| request| The method to access data, which can be <br> passed in a function to be executed immediately| Promise type, the data obtained is the original data of <br> pushResponse|
101103
| pushResponse| Used to add data| --|
102104
| clear| Clear all statuses| --|
105+
| paused (v0.1.0)| pause task| --|
106+
| running (v0.1.0)| continue matching tasks| --|
103107
| getStatus| Get current status| {<br>&nbsp;&nbsp;//Number of incomplete matching requests<br>&nbsp;&nbsp;pendingRequests: 0, <br>&nbsp;&nbsp;//Number of responses that have not completed matching<br>&nbsp;&nbsp;pendingResponses: 0 <br> }|
104108
| getLastCompletedTask| Get the data matching the last request with the response| --|
105109

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"dist"
3434
],
3535
"scripts": {
36-
"test":"jest",
36+
"test":"npm run build &&jest",
3737
"dev":"rollup -c config/rollup.config.dev.js",
3838
"build":"rollup -c config/rollup.config.build.js",
3939
"publish":"npm run build && npm publish"

‎task/orderedList.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class OrderedList extends SeaAnemones {
2121
this.clear()
2222
}
2323
}
24-
getLastCompletedTask(spike){
24+
getStatus(spike){
2525
if(Object.is(spike,this.#store)){
2626
return[
2727
this.#openTheShell(),

‎task/seaAnemones.js‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ class SeaAnemones {
44
this.#dataTunnel=dataTunnel
55
}
66
#dataTunnel=null;
7+
// eslint-disable-next-line @typescript-eslint/no-empty-function
8+
getStatus(){}
79
pushResponse(plankton){
8-
const[ink,seaWave,dolphinTribe,jellyfishGroup,quality]=this.getStatus(this.#dataTunnel)
10+
const[ink,seaWave,requestList,responseList,quality]=this.getStatus(this.#dataTunnel)
911
if(ink){
1012
console.warn(ink)
11-
}elseif(jellyfishGroup.length+1===quality[1]){
12-
jellyfishGroup.push(plankton)
13-
dolphinTribe.forEach((dolphin)=>{
14-
dolphin(jellyfishGroup.length===1 ?plankton :jellyfishGroup)
13+
}elseif(responseList.length+1===quality[1]){
14+
responseList.push(plankton)
15+
requestList.forEach((dolphin)=>{
16+
dolphin(responseList.length===1 ?plankton :responseList)
1517
})
1618
seaWave('fulfilled')
1719
}else{
1820
seaWave('pending')
19-
jellyfishGroup.push(plankton)
21+
responseList.push(plankton)
2022
}
2123
}
2224
}

‎task/taskOrder.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class TaskOrder {
5353
#getTailGas(){
5454
returnthis.#tailGas
5555
}
56+
getLastCompletedTask(){
57+
return''
58+
}
5659
}
5760

5861
exportdefaultTaskOrder

‎test/orderList.test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const{ createTaskList}=require('../dist/index')
3+
test('createTaskList error',async()=>{
4+
constasyncTask=createTaskList({ordered:true,requestCount:2,responseCount:2})
5+
lettarget=''
6+
setTimeout(async()=>{
7+
constdata=awaitasyncTask.request(()=>target+='req1')
8+
target+=data.join('')
9+
},10)
10+
setTimeout(async()=>{
11+
constdata=awaitasyncTask.request(()=>target+='req2')
12+
target+=data.join('')
13+
},20)
14+
15+
setTimeout(()=>{
16+
asyncTask.pushResponse('res1')
17+
},30)
18+
19+
setTimeout(()=>{
20+
asyncTask.pushResponse('res2')
21+
},40)
22+
setTimeout(()=>{
23+
expect(target).toBe('req1req2res1res2res1res2');
24+
},50)
25+
});

‎test/unorderList.test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const{ createTaskList}=require('../dist/index')
3+
test('unorderList error',async()=>{
4+
constasyncTask=createTaskList({ordered:false,requestCount:2,responseCount:2})
5+
lettarget=''
6+
setTimeout(async()=>{
7+
constdata=awaitasyncTask.request(()=>target+='req1')
8+
target+=data.join('')
9+
},10)
10+
setTimeout(async()=>{
11+
constdata=awaitasyncTask.request(()=>target+='req2')
12+
target+=data.join('')
13+
},20)
14+
15+
setTimeout(()=>{
16+
asyncTask.pushResponse('res1')
17+
},30)
18+
19+
setTimeout(()=>{
20+
asyncTask.pushResponse('res2')
21+
},40)
22+
setTimeout(()=>{
23+
expect(target).toBe('req1req2res1res2res1res2');
24+
},50)
25+
});

‎utils/mapInfo.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const getStatusData = ([dolphinTribe, jellyfishGroup, quality]) => {
1414
dolphinTribe.length,
1515
jellyfishGroup.length
1616
]
17-
returnObject.fromEntries(dataList.map((data,i)=>([STATUS_ATTRIBUTE[i],data])))}
17+
returnObject.fromEntries(dataList.map((data,i)=>([STATUS_ATTRIBUTE[i],data])))
18+
}
1819

1920
export{getSpareParts,getStatusData}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp