events-bluebird
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,3 +1,7 @@ | ||
## v1.0.1 | ||
* [FIXED] - use `promise.then` rather than `promise.return` method | ||
## v1.0.0 - initial release | ||
* [ADDED] - `EventEmitter.prototype.emitAsync` & `emitAsyncSeries` & `emitAsyncParallel` methods |
@@ -109,4 +109,6 @@ "use strict"; | ||
if (promiseCandidate instanceof Promise) { | ||
return promiseCandidate.return(true); | ||
if (promiseCandidate && typeof promiseCandidate.then === 'function') { | ||
return promiseCandidate.then(function() { | ||
return true; | ||
}); | ||
} else { | ||
@@ -113,0 +115,0 @@ return Promise.resolve(true); |
{ | ||
"name": "events-bluebird", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "email": "fogine@opmbx.org" |
@@ -7,3 +7,3 @@ # events-bluebird | ||
Adds `EventEmitter.prototype.emitAsyncSeries` & `EventEmitter.prototype.emitAsyncParallel` methods. The API reflects native `EventEmitter` API with the following necessary changes: | ||
* Added methods returns a Promise object which when fulfilled, returns `true` if the event had listeners, `false` otherwise | ||
* Added methods return a Promise object which when fulfilled, returns `true` if the event had listeners, `false` otherwise | ||
* node's deprecated [domain](https://nodejs.org/api/domain.html) feature is not supported | ||
@@ -15,3 +15,34 @@ | ||
Example | ||
--------------------- | ||
```javascript | ||
var EventEmitter = require('events-bluebird').EventEmitter; | ||
var emitter = new EventEmitter; | ||
emitter.on('event', function(param) { | ||
return new Promise(function(resolve, reject) { | ||
setTimeout(function() { | ||
console.log('first'); | ||
return resolve(); | ||
}, 500); | ||
}); | ||
}); | ||
emitter.on('event', function(param) { | ||
console.log('later'); | ||
}); | ||
emitter.emitAsyncSeries('event', 'param').then(function(hadListeners) { | ||
console.log(hadListeners);//true | ||
}); | ||
// Output: | ||
// first | ||
// later | ||
// true | ||
``` | ||
Tests | ||
@@ -18,0 +49,0 @@ ------------------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41090
101
50