Experimental: 'on' as alias to 'addListener'
authorRyan Dahl <ry@tinyclouds.org>
Sat, 3 Jul 2010 07:30:32 +0000 (09:30 +0200)
committerRyan Dahl <ry@tinyclouds.org>
Sat, 3 Jul 2010 07:30:32 +0000 (09:30 +0200)
lib/events.js
test/simple/test-event-emitter-add-listeners.js

index ee6e366..ee17a22 100644 (file)
@@ -75,6 +75,7 @@ process.EventEmitter.prototype.addListener = function (type, listener) {
   return this;
 };
 
+process.EventEmitter.prototype.on = process.EventEmitter.prototype.addListener;
 
 process.EventEmitter.prototype.removeListener = function (type, listener) {
   if ('function' !== typeof listener) {
index 3583fb1..c824ec6 100644 (file)
@@ -11,7 +11,7 @@ e.addListener("newListener", function (event, listener) {
   events_new_listener_emited.push(event);
 });
 
-e.addListener("hello", function (a, b) {
+e.on("hello", function (a, b) {
   console.log("hello");
   times_hello_emited += 1
   assert.equal("a", a);