Browse Source

mraleph emit hack

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
91f1b250ec
  1. 11
      lib/events.js

11
lib/events.js

@ -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++) {

Loading…
Cancel
Save