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
50bluebird_basic.js
50bluebird_basic.js
/** * basic usage of bluebird */ var Promise = require("bluebird"); //defining an async function var cl = function () { setTimeout(function () { console.log('Write something'); }, 2500); }; //promisifing a function (attaching then() method) var clAsync = Promise.promisifyAll(cl); console.log(JSON.stringify(clAsync, null, 2)); //executing promisified function clAsync() and adding new callback with then method clAsync() .then(function () { console.log('Write again'); }) .catch(function (e) { console.error(e.stack); });
Reload page
Preview
W3C validation
Edit Code
JS Console