Last active
March 14, 2018 01:19
-
-
Save AsceticBoy/c19eb0bc7f11bf8bf9f9a90fbf1d5c23 to your computer and use it in GitHub Desktop.
As for ECMAScript 6 Generator function, Can I toggle execute Permission like example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How Can I return execute permission to 'generator_B' | |
function * generator_A() { | |
yield 'ga_1' | |
yield 'ga_2' | |
yield * generator_B() | |
yield 'ga_3' | |
yield 'ga_4' | |
} | |
function * generator_B() { | |
yield 'gb_1' | |
yield 'gb_2' | |
yield * generator_A() | |
yield 'gb_3' | |
yield 'gb_4' | |
} | |
for (let val of generator_A()) { | |
console.log(val) | |
} | |
// The console is 'ga_1' -> 'ga_2' -> 'gb_1' -> 'gb_2' -> 'ga_1' -> 'ga_2' .... | |
// But I want the result is 'ga_1' -> 'ga_2' -> 'gb_1' -> 'gb_2' -> 'ga_3' -> 'ga_4' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment