mraleph emit hack

pull/5370/head
Ryan Dahl 2011-07-08 17:08:52 -07:00
parent e5564a3f29
commit 91f1b250ec
1 changed files with 8 additions and 3 deletions

View File

@ -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 (type === 'error') {
if (!this._events || !this._events.error ||
@ -68,13 +69,17 @@ EventEmitter.prototype.emit = function(type) {
break;
// slower
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);
}
return true;
} 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();
for (var i = 0, l = listeners.length; i < l; i++) {