-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
39 lines (37 loc) · 1.16 KB
/
test.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="invok.js"></script>
<script style="text/javascript">
function delay(data, delay) {
return new Promise(function(resolve){
setTimeout(function() {
resolve(data);
}, delay || 500);
});
}
invok(function*() {
console.log(yield delay("yield promise", 800));
var data1=yield (function*(){
return yield delay("yield a generator", 1500);
})();
console.log(data1);
var data2 = yield [delay(1, 100), delay(2, 300), delay(3, 1000), delay(4, 500)];
console.log(data2);
var data3 = yield {e : delay(1, 100), b : delay(2, 300), c : delay(3, 1000), d : delay(4, 500)};
console.log(data3);
console.log(yield 123);
console.log(yield {text:'普通对象'});
return "invok end";
}).then(function(data){
console.log(data);
},function(e){
console.log(e.stack)
});
</script>
</head>
<body>
</body>
</html>