-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathminibus.min.js
9 lines (7 loc) · 2.66 KB
/
minibus.min.js
1
2
3
4
5
6
7
8
9
/*! minibus - v3.1.0 - 2014-11-22
* https://github.com/axelpale/minibus
*
* Copyright (c) 2014 Akseli Palen <[email protected]>;
* Licensed under the MIT license */
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["exports"],b):b("object"==typeof exports?exports:a.Minibus={})}(this,function(a){"use strict";var b=function(){this.eventMap={},this.routeMap={},this.busContext={}};a.create=function(){return new b},a.extension=b.prototype;var c=function(a){return"[object Array]"===Object.prototype.toString.call(a)},d=function(a){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0},e=function(a){this.name="InvalidEventStringError",this.message="Invalid event string given: "+a},f=function(a){this.name="InvalidRouteStringError",this.message="Invalid route string given: "+a},g=function(a){this.name="InvalidEventHandlerError",this.message="Invalid event handler function given: "+a},h=function(a){var b,d,f,g,h,i;for(c(a)||(a=[a]),d=0;d<a.length;d+=1)if("string"!=typeof a[d])throw new e(a[d]);for(b=[],d=1;d<arguments.length;d+=1)b.push(arguments[d]);for(h=[],d=0;d<a.length;d+=1)if(this.eventMap.hasOwnProperty(a[d])){f=this.eventMap[a[d]];for(g in f)f.hasOwnProperty(g)&&h.push(f[g].eventHandler)}for(i=this.busContext,d=0;d<h.length;d+=1)h[d].apply(i,b)};b.prototype.emit=h,b.prototype.trigger=h;var i=function(a,b){var d,f,h,i,j;for(d=c(a),d||(a=[a]),f=0;f<a.length;f+=1)if("string"!=typeof a[f])throw new e(a[f]);if("function"!=typeof b)throw new g(b);for(j=[],f=0;f<a.length;f+=1)h={eventString:a[f],eventHandler:b},i=l.create(),j.push(i),this.eventMap.hasOwnProperty(a[f])||(this.eventMap[a[f]]={}),this.eventMap[a[f]][i]=h,this.routeMap[i]=h;return d?j:j[0]};b.prototype.on=i,b.prototype.listen=i;var j=function(a,b){var c,d,e;if("function"!=typeof b)throw new g(b);return c=this,e=!1,d=this.on(a,function(){e||(e=!0,c.off(d),b.apply(this,arguments))})};b.prototype.once=j;var k=function(a){var b,e,g,h,i,j;if(b="undefined"==typeof a)return this.routeMap={},void(this.eventMap={});c(a)||(a=[a]);var k=[];for(k=k.concat.apply(k,a),a=k,e=0;e<a.length;e+=1)if("string"!=typeof a[e])throw new f(a[e]);for(e=0;e<a.length;e+=1)if(this.routeMap.hasOwnProperty(a[e]))g=this.routeMap[a[e]],delete this.routeMap[a[e]],delete this.eventMap[g.eventString][a[e]],d(this.eventMap[g.eventString])&&delete this.eventMap[g.eventString];else if(h=a[e],this.eventMap.hasOwnProperty(h)){i=this.eventMap[h];for(j in i)i.hasOwnProperty(j)&&delete this.routeMap[j];delete this.eventMap[h]}};b.prototype.off=k,b.prototype.removeListener=k;var l=function(){var a={};return a.create=function(){return Math.random().toString().substring(2)},a}();a.version="3.1.0"});
//# sourceMappingURL=minibus.min.map