event-to-promise

Create a promise waiting for an event
Install
Download manually or with package-manager.
npm install --save event-to-promise
Example
var eventToPromise = require('event-to-promise');
var createServer = function (port) {
var server = require('http').createServer();
server.listen(port);
return eventToPromise(server, 'listening').then(function () {
return server;
});
};
createServer(80).then(function (server) {
console.log('Server listening on http://localhost:80/');
}).catch(function (error) {
console.error('Server could not start:', error);
});
require('bluebird').coroutine(function *() {
try {
var server = yield createServer(80);
console.log('Server listening on http://localhost:80/');
} catch (error) {
console.error('Server could not start:', error);
}
})();
Contributing
Contributions are very welcome, either on the documentation or on
the code.
You may:
- report any issue
you've encountered;
- fork and create a pull request.
License
ISC © Julien Fontanet