use generator delegation

master
Vitaliy Filippov 2016-07-22 22:54:43 +03:00
parent 20e2411845
commit e7abfb929f
1 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ function* test_throttle(thread)
console.log('at most 5');
yield setTimeout(thread, 1000);
console.log('continue in another generator');
yield gen.run(other_gen, null, thread);
yield* other_gen(thread); // same as 'yield gen.run(other_gen, null, thread)'
}
function* other_gen(thread)
@ -53,8 +53,8 @@ function* test_throw(thread)
console.log('continue');
}
//gen.run(test, null, function(result) { console.log(result); });
gen.run(test, null, function(result) { console.log(result); });
//for (var i = 0; i < 15; i++) gen.run(test_throttle);
for (var i = 0; i < 15; i++) gen.run(test_throttle);
gen.run(test_throw);