title: Javascript async function composition
body: <p>I have several async functions with varying numbers of parameters, in each the last param is a callback. I wish to call these in order. For instance.</p>
  
  <pre><code>function getData(url, callback){
  }
  function parseData(data, callback){
  }
  </code></pre>
  
  <p>By using this:</p>
  
  <pre><code>Function.prototype.then = function(f){ 
    var ff = this; 
    return function(){ ff.apply(null, [].slice.call(arguments).concat(f)) } 
  }
  </code></pre>
  
  <p>it is possible to call these functions like this, and have the output print to console.log.</p>
  
  <pre><code>getData.then(parseData.then(console.log.bind(console)))('/mydata.json');
  </code></pre>
  
  <p>I've been trying to use this syntax instead, and cannot get the Then function correct. Any ideas?</p>
  
  <pre><code>getData.then(parseData).then(console.log.bind(console))('/mydata.json');
  </code></pre>