Skip to content

Instantly share code, notes, and snippets.

@AsceticBoy
Last active March 14, 2018 01:19
Show Gist options
  • Save AsceticBoy/c19eb0bc7f11bf8bf9f9a90fbf1d5c23 to your computer and use it in GitHub Desktop.
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
// 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