feat(server.tests.test7): 新增 server 实验 7
This commit is contained in:
@@ -19,5 +19,6 @@
|
|||||||
├── test3 # 实验3
|
├── test3 # 实验3
|
||||||
├── test4 # 实验4
|
├── test4 # 实验4
|
||||||
├── test5 # 实验5
|
├── test5 # 实验5
|
||||||
└── test6 # 实验6
|
├── test6 # 实验6
|
||||||
|
└── test7 # 实验7
|
||||||
```
|
```
|
||||||
|
|||||||
2
Server/tests/test7/.gitignore
vendored
Normal file
2
Server/tests/test7/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
pnpm-lock.yaml
|
||||||
12
Server/tests/test7/index.js
Normal file
12
Server/tests/test7/index.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
console.log("开始");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("Timeout");
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
console.log("Immediate");
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("结束");
|
||||||
|
|
||||||
23
Server/tests/test7/index2.js
Normal file
23
Server/tests/test7/index2.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
console.log("Start");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("Timeout1");
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
let a = 1;
|
||||||
|
const intervalId = setInterval(() => {
|
||||||
|
console.log(a++);
|
||||||
|
clearInterval(this);
|
||||||
|
clearInterval(intervalId)
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("Timeout2");
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
console.log("Immediate");
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("End");
|
||||||
|
|
||||||
27
Server/tests/test7/index3.js
Normal file
27
Server/tests/test7/index3.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
console.log("Start");
|
||||||
|
|
||||||
|
fs.readFile(path.join(__dirname, "/example.html"), 'utf8', (err, data) => {
|
||||||
|
console.log(data);
|
||||||
|
if (err) {
|
||||||
|
console.log(__dirname);
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("Timeout");
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
console.log("Immediate");
|
||||||
|
});
|
||||||
|
|
||||||
|
process.nextTick(() => {
|
||||||
|
console.log("Next Tick");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log("End");
|
||||||
|
|
||||||
21
Server/tests/test7/index4.js
Normal file
21
Server/tests/test7/index4.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
console.log("Start");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
console.log("Timeout");
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
setImmediate(() => {
|
||||||
|
console.log("Immediate");
|
||||||
|
});
|
||||||
|
|
||||||
|
process.nextTick(() => {
|
||||||
|
console.log("Next Tick 1");
|
||||||
|
});
|
||||||
|
|
||||||
|
process.nextTick(() => {
|
||||||
|
console.log("Next Tick 2");
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("End");
|
||||||
|
|
||||||
|
|
||||||
13
Server/tests/test7/package.json
Normal file
13
Server/tests/test7/package.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "test7",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"packageManager": "pnpm@10.14.0"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user