title: IsGenerator implementation
body: <p>I previously relied on the following definition of how to detect a generator:</p>
  
  <pre><code>function isGenerator(func) {
      return func instanceof Function &amp;&amp; func.constructor.name === 'GeneratorFunction';
  }
  </code></pre>
  
  <p>Since then however I came across various other verifications, including checks for <code>next</code> and <code>throw</code> functions on the prototype.</p>
  
  <p>Is there a way to implement <code>isGenerator</code> function to be considered comprehensive within the realm of NodeJS 0.10 - 5.x?</p>
  
  <p>The application in which I intend to use is to pick up any generator (or even iterator), and wrap it up into a promise that would make use of functions <code>next</code> and <code>throw</code>.</p>
  
  <p>For that I'm using a modified example from <a href="https://www.promisejs.org/generators/#both" rel="nofollow">here</a>:</p>
  
  <pre><code>/////////////////////////////////
  // Generator-to-Promise adapter;
  function asyncAdapter(generator) {
      return function () {
          var g = generator.apply(this, arguments);
  
          function handle(result) {
              if (result.done) {
                  return Promise.resolve(result.value);
              }
              return Promise.resolve(result.value)
                  .then(function (res) {
                      return handle(g.next(res));
                  }, function (err) {
                      return handle(g.throw(err));
                  });
          }
  
          return handle(g.next());
      }
  }
  </code></pre>