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)
|
if (this.domain && this !== process)
|
||||||
this.domain.enter();
|
this.domain.enter();
|
||||||
|
|
||||||
if (typeof handler == 'function') {
|
if (typeof handler === 'function') {
|
||||||
switch (arguments.length) {
|
switch (arguments.length) {
|
||||||
// fast cases
|
// fast cases
|
||||||
case 1:
|
case 1:
|
||||||
@ -267,11 +267,14 @@ EventEmitter.prototype.removeAllListeners = function(type) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.prototype.listeners = function(type) {
|
EventEmitter.prototype.listeners = function(type) {
|
||||||
|
var ret;
|
||||||
if (!this._events || !this._events[type])
|
if (!this._events || !this._events[type])
|
||||||
return [];
|
ret = [];
|
||||||
if (typeof this._events[type] === 'function')
|
else if (typeof this._events[type] === 'function')
|
||||||
return [this._events[type]];
|
ret = [this._events[type]];
|
||||||
return this._events[type].slice();
|
else
|
||||||
|
ret = this._events[type].slice();
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.listenerCount = function(emitter, type) {
|
EventEmitter.listenerCount = function(emitter, type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user