diff --git a/lib/events.js b/lib/events.js index 2a83ab7dc64c7b..db7b57cee037be 100644 --- a/lib/events.js +++ b/lib/events.js @@ -342,6 +342,8 @@ EventEmitter.prototype.removeListener = return this; }; +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) { var listeners, events, i; diff --git a/test/parallel/test-event-emitter-method-names.js b/test/parallel/test-event-emitter-method-names.js index c74b88aff7acf2..684024d0276261 100644 --- a/test/parallel/test-event-emitter-method-names.js +++ b/test/parallel/test-event-emitter-method-names.js @@ -27,8 +27,9 @@ const events = require('events'); const E = events.EventEmitter.prototype; assert.strictEqual(E.constructor.name, 'EventEmitter'); assert.strictEqual(E.on, E.addListener); // Same method. +assert.strictEqual(E.off, E.removeListener); // Same method. Object.getOwnPropertyNames(E).forEach(function(name) { - if (name === 'constructor' || name === 'on') return; + if (name === 'constructor' || name === 'on' || name === 'off') return; if (typeof E[name] !== 'function') return; assert.strictEqual(E[name].name, name); });