1function* g1() {
2 yield 2;
3 yield 3;
4 yield 4;
5}
6
7function* g2() {
8 yield 1;
9 yield* g1();
10 yield 5;
11}
12
13const iterator = g2();
14
15console.log(iterator.next()); // {value: 1, done: false}
16console.log(iterator.next()); // {value: 2, done: false}
17console.log(iterator.next()); // {value: 3, done: false}
18console.log(iterator.next()); // {value: 4, done: false}
19console.log(iterator.next()); // {value: 5, done: false}
20console.log(iterator.next()); // {value: undefined, done: true}
21