Better Fix *,* or someEvent,* thanks @hxsf and @conordickinson

This commit is contained in:
SSMP 2016-08-26 18:20:02 -07:00
parent aa34d14485
commit f955b96dd2
3 changed files with 5 additions and 18 deletions

View file

@ -22,28 +22,14 @@ window.pubsub=(
} }
checkScope.apply(this); checkScope.apply(this);
if(type=='*'){
var params=Array.prototype.slice.call(arguments,1);
for(
var keys = Object.keys(this._events_),
count = keys.length,
i=0;
i<count;
i++
){
params.unshift(keys[i]);
this.off.apply(this,params);
}
}
if(!this._events_[type])
return;
if(handler=='*'){ if(handler=='*'){
delete this._events_[type]; delete this._events_[type];
return; return;
} }
if(!this._events_[type])
return;
for(var i=0, for(var i=0,
count=this._events_[type].length; count=this._events_[type].length;
i<count; i<count;

View file

@ -21,6 +21,7 @@ function unsub(type,handler){
if(handler=='*'){ if(handler=='*'){
delete this._events_[type]; delete this._events_[type];
return;
} }
if(!this._events_[type]) if(!this._events_[type])

View file

@ -1,6 +1,6 @@
{ {
"name": "event-pubsub", "name": "event-pubsub",
"version": "2.1.2", "version": "2.2.0",
"description": "Pubsub events for Node and the browser allowing event scoping and multiple scopes. Easy for any developer level. No frills, just high speed pubsub events!", "description": "Pubsub events for Node and the browser allowing event scoping and multiple scopes. Easy for any developer level. No frills, just high speed pubsub events!",
"main": "event-pubsub.js", "main": "event-pubsub.js",
"directories": { "directories": {