FIX: EventEmitter#removeAllListeners signature
authorJonas Pfenniger <jonas@pfenniger.name>
Fri, 14 May 2010 11:13:27 +0000 (13:13 +0200)
committerRyan Dahl <ry@tinyclouds.org>
Sat, 15 May 2010 02:15:07 +0000 (19:15 -0700)
This function should return this is all cases.

lib/events.js

index 682a928..ee6e366 100644 (file)
@@ -99,8 +99,8 @@ process.EventEmitter.prototype.removeListener = function (type, listener) {
 
 process.EventEmitter.prototype.removeAllListeners = function (type) {
   // does not use listeners(), so no side effect of creating _events[type]
-  if (!type || !this._events || !this._events[type]) return this;
-  this._events[type] = null;
+  if (type && this._events && this._events[type]) this._events[type] = null;
+  return this;
 };
 
 process.EventEmitter.prototype.listeners = function (type) {