lib/js/event_emitter.js in sinatra-websocketio-0.1.6 vs lib/js/event_emitter.js in sinatra-websocketio-0.1.7
- old
+ new
@@ -1,6 +1,6 @@
-// event_emitter.js v0.0.7
+// event_emitter.js v0.0.8
// https://github.com/shokai/event_emitter.js
// (c) 2013 Sho Hashimoto <hashimoto@shokai.org>
// The MIT License
var EventEmitter = function(){
var self = this;
@@ -36,33 +36,36 @@
for(var i = 0; i < self.__events.length; i++){
var e = self.__events[i];
switch(e.type){
case type:
e.listener(data);
+ if(e.once) e.type = null;
break
- case '*':
+ case "*":
e.listener(type, data);
+ if(e.once) e.type = null;
break
}
- if(e.once) self.removeListener(e.id);
}
+ self.removeListener();
};
this.removeListener = function(id_or_type){
for(var i = self.__events.length-1; i >= 0; i--){
var e = self.__events[i];
switch(typeof id_or_type){
case "number":
- if(e.id == id_or_type) self.__events.splice(i,1);
+ if(e.id === id_or_type) self.__events.splice(i,1);
break
case "string":
- if(e.type == id_or_type) self.__events.splice(i,1);
+ case "object":
+ if(e.type === id_or_type) self.__events.splice(i,1);
break
}
}
};
};
-if(typeof module !== 'undefined' && typeof module.exports !== 'undefined'){
+if(typeof module !== "undefined" && typeof module.exports !== "undefined"){
module.exports = EventEmitter;
}