Skip to content

Instantly share code, notes, and snippets.

@cgrinaldi
Created June 14, 2015 23:18
Show Gist options
  • Save cgrinaldi/aa4c283d6fdac767eb25 to your computer and use it in GitHub Desktop.
Save cgrinaldi/aa4c283d6fdac767eb25 to your computer and use it in GitHub Desktop.
An example of properly using promises (no deferred!)
var getConfig = function() {
var readFile = Q.nfbind(fs.readFile);
return readFile(CONFIG_DIR + '/aFile.conf', 'utf-8').then(function(data) {
var configJSON = helpers.configStr2JSON(data, true);
return configJSON;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment