Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
nodejs
promises
51bluebird_fs.js
51bluebird_fs.js
/** * basic usage of bluebird */ var Promise = require("bluebird"); var fs = Promise.promisifyAll(require("fs")); console.log(JSON.stringify(fs, null, 2)); fs.readFileAsync("../testfiles/readMe.txt", "utf8") .then(function (fileContent) { console.log(fileContent); return fs.readFileAsync("badFile.txt", "utf8") .then(function () { console.log('Second file is tried to read.'); }); }) .then(function () { console.log('Finished!!!'); }) .catch(function (e) { console.error(e.stack); });
Reload page
Preview
W3C validation
Edit Code
JS Console