3 lines
984 B
JavaScript
3 lines
984 B
JavaScript
// Licenced under MIT - castrato - ©2014 Pehr Boman <github.com/unkelpehr>
|
|
(function(f,g){"function"===typeof define&&define.amd?define([],g()):"object"===typeof exports?module.exports=g:f.castrato=g})(this,function(){function f(e,a,b,c){var d=[e,b,1<b.length];(l[a]||(l[a]=[])).push(d);if(m[a])for(e=0,d=[d];(b=m[a][e++])&&(k(0,0,b[0],b[1],d),!c););}function g(e,a,b){var c=0;if(toSubs=l[a])for(;a=toSubs[c++];)a[0]!==e||b&&b!==a[1]||toSubs.splice(--c,1)}function k(e,a,b,c,d){var g=d||l[a]||[],h=g.length,f=h,k=h,n=[],p;if(k)for(p=c?function(a){a&&n.push(a);--f||(c(n,h),c=0)}:
|
|
q;d=g[--k];)d[1](b,d[2]?p:f--);!f&&c&&c(n,h);e&&(m[a]||(m[a]=[])).push([b,c])}var r=0,l={},m={},q=function(){};return function(){var e=r++;return{emit:function(a,b,c,d){!0!==a&&!1!==a&&(d=c,c=b,b=a,a=!1);k(a,b,c,d);return this},on:function(a,b){f(e,a,b);return this},once:function(a,b){f(e,a,function d(f,h){g(e,a,d);b(f,1<b.length?h:h())},!0);return this},off:function(a,b){g(e,a,b);return this}}}}()); |