forked from bailicangdu/node-elm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
54 lines (45 loc) · 1.29 KB
/
Copy pathtest.js
File metadata and controls
54 lines (45 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
class Mytest {
constructor() {
}
//做饭
async cook() {
console.log('开始做饭。');
var p = new Promise(function (resolve, reject) { //做一些异步操作
setTimeout(function () {
console.log('做饭完毕!');
resolve('鸡蛋炒饭');
}, 1000);
});
console.log('----------。');
return p;
}
//吃饭
async eat(data) {
console.log('开始吃饭:' + data);
var p = new Promise(function (resolve, reject) { //做一些异步操作
setTimeout(function () {
console.log('吃饭完毕!');
resolve('一块碗和一双筷子');
}, 2000);
});
return p;
}
async wash(data) {
console.log('开始洗碗:' + data);
var p = new Promise(function (resolve, reject) { //做一些异步操作
setTimeout(function () {
console.log('洗碗完毕!');
resolve('干净的碗筷');
}, 2000);
});
return p;
}
async test(){
await this.cook();
await this.eat();
await this.wash();
console.log('test end...');
}
}
module.exports = new Mytest();