We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7fd55e commit 56668f5Copy full SHA for 56668f5
lib/events.js
@@ -239,6 +239,17 @@ EventEmitter.prototype.removeListener = function(type, listener) {
239
EventEmitter.prototype.removeAllListeners = function(type) {
240
if (!this._events) return this;
241
242
+ // fast path
243
+ if (!this._events.removeListener) {
244
+ if (arguments.length === 0) {
245
+ this._events = {};
246
+ } else if (type && this._events && this._events[type]) {
247
+ this._events[type] = null;
248
+ }
249
+ return this;
250
251
+
252
+ // slow(ish) path, emit 'removeListener' events for all removals
253
if (arguments.length === 0) {
254
for (var key in this._events) {
255
if (key === 'removeListener') continue;
0 commit comments