title: Pass arguments to a generator function
body: <p>I have been totally stuck at this for the last few hours.</p>
  
  <p><strong>How to pass paramters to a generator function?</strong></p>
  
  <pre><code>function* getFoo(foo) {
      return yield Promise.resolve(foo + 10);
  }
  
  exports.testRoute = Promise.coroutine(function* (req, res) {
      let bar = yield Promise.coroutine(getFoo);  // &lt;--- how to pass argument??
      res.send(bar.toString());
  });
  </code></pre>
  
  <p><strong>Current Code throws Error</strong> (and I know it points me to <a href="https://github.com/petkaantonov/bluebird/wiki/Error:-A-value-was-yielded-that-could-not-be-treated-as-a-promise" rel="nofollow noreferrer">here</a> but it doesn't say anything about argument passing):</p>
  
  <pre><code>Unhandled rejection TypeError: A value [object Promise] was yielded that could not be treated as a promise
      See http:// goo.gl/4Y4pDk
  From coroutine:
      at Function.module.exports.Promise.coroutine (d:\Workspace\Github\API-NodeJS\app\node_modules\bluebird\js\main\generators.js:111:17)
  </code></pre>
  
  <p><strong>If I do this:</strong></p>
  
  <pre><code>let bar = yield Promise.coroutine(getFoo(5));
  </code></pre>
  
  <p>I get following Error (again self explanatory error, but <a href="https://github.com/petkaantonov/bluebird/wiki/Error:-generatorFunction-must-be-a-function" rel="nofollow noreferrer">this link</a> doesn't explain argument passing either):</p>
  
  <pre><code>Unhandled rejection TypeError: generatorFunction must be a function
      See http:// goo.gl/6Vqhm0
      at Function.module.exports.Promise.coroutine (d:\Workspace\Github\API-NodeJS\app\node_modules\bluebird\js\main\generators.js:107:15)
  </code></pre>