Call the generator from the generator
I would like to call a generator from another generator by getting its "steps". Although I can't seem to find a good syntax for this.
function* test1() {
yield 2;
yield 3;
}
function* test2() {
yield 1;
for (var i of test1()) yield i; // WTF
yield 4;
}
var a = test2();
for (var b of a) {
console.log(b);
}
Output: 1 2 3 4
How can I shorten this line?
+3
source to share