title: Difference between async/await and ES6 yield with generators
body: <p>I was just reading this fantastic article «<a href="https://www.promisejs.org/generators" rel="noreferrer">Generators</a>» and it clearly highlights this function, which is a helper function for handling generator functions:</p>
  
  <pre class="lang-js prettyprint-override"><code>function async(makeGenerator){
    return function () {
      var generator = makeGenerator.apply(this, arguments);
  
      function handle(result){
        // result =&gt; { done: [Boolean], value: [Object] }
        if (result.done) return Promise.resolve(result.value);
  
        return Promise.resolve(result.value).then(function (res){
          return handle(generator.next(res));
        }, function (err){
          return handle(generator.throw(err));
        });
      }
  
      try {
        return handle(generator.next());
      } catch (ex) {
        return Promise.reject(ex);
      }
    }
  }
  </code></pre>
  
  <p><em>which I hypothesize is more or less the way the <code>async</code> keyword is implemented with <code>async</code>/<code>await</code>.</em> So the question is, if that is the case, then what the heck is the difference between the <code>await</code> keyword and the <code>yield</code> keyword? Does <code>await</code> always turn something into a promise, whereas <code>yield</code> makes no such guarantee? That is my best guess!</p>
  
  <p>You can also see how <code>async</code>/<code>await</code> is similar to <code>yield</code> with generators in this article where he describes the 'spawn' function <a href="https://jakearchibald.com/2014/es7-async-functions" rel="noreferrer">ES7 async functions</a>.</p>