title: How to conditionally stop a JavaScript generator?
body: <p>With an iterator like the following one:</p>
  
  <pre><code>function* idMaker(){
      let index = 0;
      while(index &lt; 3)
          yield index++;
  }
  </code></pre>
  
  <p>How can I make sure to stop the generator prematurely based on a condition?</p>
  
  <pre><code>function* idMaker(){
      let index = 0;
      while(index &lt; 3)
          if (checker(index))
              yield index++;
          else
              return;
  }
  </code></pre>
  
  <p>Is it okay appropriate to use in a generator? Should I use <code>break</code> instead of <code>yield break</code> perhaps like in C#?</p>
  
  <p>Can you include a link to MDN or spec where this is discussed?</p>