-
Notifications
You must be signed in to change notification settings - Fork 1
/
evemit.min.js
1 lines (1 loc) · 1.23 KB
/
evemit.min.js
1
/*! evemit v1.0.0 | MIT (c) 2014 Nicolas Tallefourtane - https://github.com/Nicolab/evemit */!function(){"use strict";function t(){this.events={}}t.prototype.on=function(t,e,n){return this.events[t]||(this.events[t]=[]),n&&(e._E_ctx=n),this.events[t].push(e),this},t.prototype.once=function(t,e,n){return e._E_once=!0,this.on(t,e,n)},t.prototype.emit=function(t,e,n,s,r){var i,o,c,u;if(!this.events[t])return!1;c=Array.prototype.slice.call(arguments,1),u=c.length,o=this.events[t];for(var a=0,l=o.length;l>a;a++)switch(i=o[a],i._E_once&&this.off(t,i),u){case 0:i.call(i._E_ctx);break;case 1:i.call(i._E_ctx,e);break;case 2:i.call(i._E_ctx,e,n);break;case 3:i.call(i._E_ctx,e,n,s);break;case 4:i.call(i._E_ctx,e,n,s,r);break;default:i.apply(i._E_ctx,c)}return!0},t.prototype.off=function(t,e){if(!this.events[t])return this;for(var n=0,s=this.events[t].length;s>n;n++)this.events[t][n]===e&&(this.events[t][n]=null,delete this.events[t][n]);return this.events[t]=this.events[t].filter(function(t){return"undefined"!=typeof t}),this},t.prototype.listeners=function(t){var e,n;if(t)return this.events[t]||[];e=this.events,n=[];for(var s in e)n=n.concat(e[s].valueOf());return n},"undefined"!=typeof module&&module.exports?module.exports=t:window.Evemit=t}();