title: Promise with q framework and the callback pattern in Node.js?
body: <p>Even if well documented <a href="https://github.com/kriskowal/q" rel="nofollow">q framework</a> is quite hard to understand if you are programming with Node.js for a few days. But I like to learn about it!</p>
  
  <pre><code>var Q  = require('q');
  var fs = require('fs');
  
  // Make the promise manually (returns a value or throws an error)
  var read1 = fs.readFile(fname, enc, function (err, data) {
      if(err) throw err;
  
      return data;
  });
  
  // Convenient helper for node, equivalent to read1?
  var read2 = Q.nfbind(fs.readFile);
  
  // Uh?!
  var read3 = function (fname, enc) {
      var deferred = Q.defer();
  
      fs.readFile(fname, enc, function (error, text) {
          if (error) {
              deferred.reject(new Error(error));
          } else {
              deferred.resolve(text);
          }
  
          return deferred.promise;
      });
  };
  
  
  // Execute
  Q.fncall(read1).then(function (data) {}, function (err) {}).done();
  </code></pre>
  
  <p>Are <code>read1</code>, <code>read2</code> and <code>read3</code> equivalent? Can I use <code>Q.nfbind</code> every time the last parameter of a function accept a callback in the style of <code>function (err, value)</code>?</p>