Browse Source

Experimental: 'on' as alias to 'addListener'

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
515dc2161b
  1. 1
      lib/events.js
  2. 2
      test/simple/test-event-emitter-add-listeners.js

1
lib/events.js

@ -75,6 +75,7 @@ process.EventEmitter.prototype.addListener = function (type, listener) {
return this; return this;
}; };
process.EventEmitter.prototype.on = process.EventEmitter.prototype.addListener;
process.EventEmitter.prototype.removeListener = function (type, listener) { process.EventEmitter.prototype.removeListener = function (type, listener) {
if ('function' !== typeof listener) { if ('function' !== typeof listener) {

2
test/simple/test-event-emitter-add-listeners.js

@ -11,7 +11,7 @@ e.addListener("newListener", function (event, listener) {
events_new_listener_emited.push(event); events_new_listener_emited.push(event);
}); });
e.addListener("hello", function (a, b) { e.on("hello", function (a, b) {
console.log("hello"); console.log("hello");
times_hello_emited += 1 times_hello_emited += 1
assert.equal("a", a); assert.equal("a", a);

Loading…
Cancel
Save