Hacker News new | past | comments | ask | show | jobs | submit login

I mean, you could look at the examples in the article and see that, yes, they resume from a yield point. But here's a simple illustrative example:

  function* bar() {
    yield 3;
    console.log("Resumed after the 3")
    yield 4;
    console.log("Resumed after the 4")
  }
  function* foo() {
    yield 1;
    console.log("Resumed after the 1")
    yield 2;
    console.log("Resumed after the 2")
    yield* bar();
  }

  for(let n of foo()) {
    console.log(n);
  }
Output:

  1
  Resumed after the 1
  2
  Resumed after the 2
  3
  Resumed after the 3
  4
  Resumed after the 4



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: