|
@ -35,7 +35,8 @@ EventEmitter.prototype.setMaxListeners = function(n) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventEmitter.prototype.emit = function(type) { |
|
|
EventEmitter.prototype.emit = function() { |
|
|
|
|
|
var type = arguments[0]; |
|
|
// If there is no 'error' event listener then throw.
|
|
|
// If there is no 'error' event listener then throw.
|
|
|
if (type === 'error') { |
|
|
if (type === 'error') { |
|
|
if (!this._events || !this._events.error || |
|
|
if (!this._events || !this._events.error || |
|
@ -68,13 +69,17 @@ EventEmitter.prototype.emit = function(type) { |
|
|
break; |
|
|
break; |
|
|
// slower
|
|
|
// slower
|
|
|
default: |
|
|
default: |
|
|
var args = Array.prototype.slice.call(arguments, 1); |
|
|
var l = arguments.length; |
|
|
|
|
|
var args = new Array(l - 1); |
|
|
|
|
|
for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; |
|
|
handler.apply(this, args); |
|
|
handler.apply(this, args); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
|
|
|
|
|
|
} else if (isArray(handler)) { |
|
|
} else if (isArray(handler)) { |
|
|
var args = Array.prototype.slice.call(arguments, 1); |
|
|
var l = arguments.length; |
|
|
|
|
|
var args = new Array(l - 1); |
|
|
|
|
|
for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; |
|
|
|
|
|
|
|
|
var listeners = handler.slice(); |
|
|
var listeners = handler.slice(); |
|
|
for (var i = 0, l = listeners.length; i < l; i++) { |
|
|
for (var i = 0, l = listeners.length; i < l; i++) { |
|
|