Permalink
Browse files

Updating 'events' to version 0.1.1

  • Loading branch information...
1 parent fede0c5 commit 62726d2c33c4136f9e090b62ea2fbd95adb24e51 @Gozala committed May 16, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/events.js
View
@@ -18,14 +18,19 @@ var isArray = Array.isArray;
var MAX_LISTENERS = 10;
var ERROR_TYEPE = 'error';
+exports.version = "0.1.1";
exports.EventEmitter = Extendable.extend({
setMaxListeners: function setMaxListeners(n) {
if (!this._events) this._events = {};
this._events.maxListeners = n;
},
emit: function emit(type) {
var args = Array.prototype.slice.call(arguments, 1);
- this.listeners(type).forEach(function(listener) {
+ var listeners = this.listeners(type);
+ if (type === ERROR_TYEPE && !listeners.length)
+ console.error(args[0]);
+
+ listeners.forEach(function(listener) {
try {
listener.apply(this, args);
} catch (error) {
@@ -138,6 +143,4 @@ exports.EventEmitter = Extendable.extend({
}
});
-exports.version = "0.1.0";
-
});

0 comments on commit 62726d2

Please sign in to comment.