[Pkg-javascript-commits] [sockjs-client] 421/434: updates to EventEmitter class (events -> _events, etc)

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit 06d07c9dee21cd9e3c87fe3004997c4d3f2c54d7
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Tue May 22 17:22:08 2012 +0100

    updates to EventEmitter class (events -> _events, etc)
---
 lib/eventemitter.js | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/eventemitter.js b/lib/eventemitter.js
index ddcce8c..0ea96a9 100644
--- a/lib/eventemitter.js
+++ b/lib/eventemitter.js
@@ -7,25 +7,32 @@
  */
 
 var EventEmitter = function(events) {
-    this.events = events || [];
+    var that = this;
+    that._events = events || [];
 };
 EventEmitter.prototype.emit = function(type) {
     var that = this;
+    that._verifyType(type);
+    if (that._nuked) return;
+
     var args = Array.prototype.slice.call(arguments, 1);
-    if (!that.nuked && that['on'+type]) {
+    if (that['on'+type]) {
         that['on'+type].apply(that, args);
     }
-    if (utils.arrIndexOf(that.events, type) === -1) {
+};
+EventEmitter.prototype._verifyType = function(type) {
+    var that = this;
+    if (utils.arrIndexOf(that._events, type) === -1) {
         utils.log('Event ' + JSON.stringify(type) +
-                  ' not listed ' + JSON.stringify(that.events) +
+                  ' not listed ' + JSON.stringify(that._events) +
                   ' in ' + that);
     }
 };
 
-EventEmitter.prototype.nuke = function(type) {
+EventEmitter.prototype.nuke = function() {
     var that = this;
-    that.nuked = true;
-    for(var i=0; i<that.events.length; i++) {
-        delete that[that.events[i]];
+    that._nuked = true;
+    for(var i=0; i<that._events.length; i++) {
+        delete that[that._events[i]];
     }
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list