title: How can I pass a callback to a generator that I pass to the "vo" library?
body: <p>I am trying to understand how callbacks work so I created a function and passed a second argument named 'callback', which I call at the end of the function with 'callback(arr)' . However I am getting an error which says : "callback is not a function" ? Can you please tell me what I am doing wrong?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>vo is a nodejs library that takes a generator function* () and runs all it's yields . It's basically a way to handle async code with less callbacks (yes I know I used a callback as well but that's pretty much a choice). A more popular library that does exactly the same thing is co. Link to vo: <a href="https://github.com/matthewmueller/vo" rel="noreferrer">https://github.com/matthewmueller/vo</a></p>
  
  <pre><code>var Nightmare = require('nightmare');
  var vo = require('vo');
  
  function* MyFunction(query, callback) {
      arr = [];
      for (i = 0; i &lt; 1; i++) {
          arr.push(yield Nightmare({
                  show: true
              }).goto(`http://google.com`)
              .inject('js', 'jquery-3.1.0.js')
              .evaluate(() =&gt; {
                  var title;
                  title = 1
                  extend = 2
                  var img;
                  img = 3
                  var par;
                  par = 4
                  url = window.location.href;
                  var par_arr = [5, 5, 5, 5];
  
  
                  return {
                      title: title,
                      img: img,
                      par: par,
                      par_arr: par_arr,
                      url: url
                  }
  
              }).end()
              .catch(function(error, nightmare) {
  
                  console.error('Search failed:', error);
              }))
      }
  
      callback(arr);
  
      return arr;
  }
  
  vo(MyFunction)('query', (arr) =&gt; {
      console.log(arr);
  });
  </code></pre>