events: code consistency
v8 likes when smaller functions have a single return point, and cleaned up the single non-strict check.
This commit is contained in:
parent
04688614f7
commit
d09ab61dcd
@ -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…
x
Reference in New Issue
Block a user