Browse Source

events: code consistency

v8 likes when smaller functions have a single return point, and cleaned
up the single non-strict check.
v0.9.12-release
Trevor Norris 12 years ago
parent
commit
d09ab61dcd
  1. 13
      lib/events.js

13
lib/events.js

@ -84,7 +84,7 @@ EventEmitter.prototype.emit = function(type) {
if (this.domain && this !== process)
this.domain.enter();
if (typeof handler == 'function') {
if (typeof handler === 'function') {
switch (arguments.length) {
// fast cases
case 1:
@ -267,11 +267,14 @@ EventEmitter.prototype.removeAllListeners = function(type) {
};
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
return [];
if (typeof this._events[type] === 'function')
return [this._events[type]];
return this._events[type].slice();
ret = [];
else if (typeof this._events[type] === 'function')
ret = [this._events[type]];
else
ret = this._events[type].slice();
return ret;
};
EventEmitter.listenerCount = function(emitter, type) {

Loading…
Cancel
Save