Skip to content

Instantly share code, notes, and snippets.

@shaikh-shahid
Last active April 6, 2016 07:35
Show Gist options
  • Save shaikh-shahid/2b427fa96a3bbcd613b1467d339a9706 to your computer and use it in GitHub Desktop.
Save shaikh-shahid/2b427fa96a3bbcd613b1467d339a9706 to your computer and use it in GitHub Desktop.
var Promise = require('bluebird');
// Converts all function of 'fs' into promises.
var fs = Promise.promisifyAll(require('fs'));
fs.readFileAsync('file.js','utf8')
// 'then' when result comes.
.then(function(data) {
console.log(data);
})
//'catch' when error comes.
.catch(function(err) {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment