Last active
April 6, 2016 07:35
-
-
Save shaikh-shahid/2b427fa96a3bbcd613b1467d339a9706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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