-
Notifications
You must be signed in to change notification settings - Fork 1
/
PubSub.min.js
1 lines (1 loc) · 1.45 KB
/
PubSub.min.js
1
(function(a,c,b){var d=typeof module=="object"&&typeof require=="function";if(d){module.exports=b(a,c)}else{if(typeof define==="function"&&typeof define.amd==="object"){define(b)}else{c[a]=b(a,c)}}}("PubSub",(typeof window!=="undefined"&&window)||this,function definition(a,b){var l={name:"PubSubJS",version:"1.3.2"},g={},j=-1;function k(n){return function m(){throw n}}function d(n,o,p){try{n(o,p)}catch(m){setTimeout(k(m),0)}}function h(m,n,o){m(n,o)}function f(n,q,r,t){var s=g[q],m=t?h:d,p,o;if(!g.hasOwnProperty(q)){return}for(p=0,o=s.length;p<o;p++){m(s[p].func,n,r)}}function e(m,n,p){return function o(){var r=String(m),q=r.lastIndexOf(".");f(m,m,n,p);while(q!==-1){r=r.substr(0,q);q=r.lastIndexOf(".");f(m,r,n)}}}function i(o){var n=String(o),p=g.hasOwnProperty(n),m=n.lastIndexOf(".");while(!p&&m!==-1){n=n.substr(0,m);m=n.lastIndexOf(".");p=g.hasOwnProperty(n)}return p}function c(o,p,n,r){var q=e(o,p,r),m=i(o);if(!m){return false}if(n===true){q()}else{setTimeout(q,0)}return true}l.publish=function(m,n){return c(m,n,false,l.immediateExceptions)};l.publishSync=function(m,n){return c(m,n,true,l.immediateExceptions)};l.subscribe=function(o,n){if(!g.hasOwnProperty(o)){g[o]=[]}var m=String(++j);g[o].push({token:m,func:n});return m};l.unsubscribe=function(u){var s=typeof u==="string",r=s?"token":"func",t=s?u:true,o=false,n,q,p;for(n in g){if(g.hasOwnProperty(n)){for(q=g[n].length-1;q>=0;q--){if(g[n][q][r]===u){g[n].splice(q,1);o=t;if(s){return o}}}}}return o};return l}));