Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tsed/event-emitter

Package Overview
Dependencies
Maintainers
0
Versions
600
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsed/event-emitter - npm Package Compare versions

Comparing version 8.3.4 to 8.3.5

2

lib/browser/event-emitter.umd.min.js
/*! For license information please see event-emitter.umd.min.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tsed/core"),require("@tsed/di")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/di"],t):"object"==typeof exports?exports["@tsed/event-emitter"]=t(require("@tsed/core"),require("@tsed/di")):e["@tsed/event-emitter"]=t(e["@tsed/core"],e["@tsed/di"])}(self,((e,t)=>(()=>{var r={124:(e,t,r)=>{var n;!function(i){var s=Object.hasOwnProperty,o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},l="object"==typeof process&&"function"==typeof process.nextTick,a="function"==typeof Symbol,c="object"==typeof Reflect,f="function"==typeof setImmediate?setImmediate:setTimeout,h=a?c&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function u(){this._events={},this._conf&&p.call(this,this._conf)}function p(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==i&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function v(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var y=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function m(e,t){for(var r={},n=e.length,s=t?t.length:0,o=0;o<n;o++)r[e[o]]=o<s?t[o]:i;return r}function d(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var s=e._observers;s?s.push(this):e._observers=[this]}function _(e,t,r,n){var o=Object.assign({},t);if(!e)return o;if("object"!=typeof e)throw TypeError("options must be an object");var l,a,c,f=Object.keys(e),h=f.length;function u(e){throw Error('Invalid "'+l+'" option value'+(e?". Reason: "+e:""))}for(var p=0;p<h;p++){if(l=f[p],!n&&!s.call(t,l))throw Error('Unknown "'+l+'" option');(a=e[l])!==i&&(c=r[l],o[l]=c?c(a,u):a)}return o}function b(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function g(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var s=typeof e;if(s===n||s===i)return e;r(t)}:function(n,i){for(var s=typeof n,o=r;o-- >0;)if(s===e[o])return n;i(t)}}Object.assign(d.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,s=this._emitter,o=this._listeners,l=function(){var n=y.apply(null,arguments),o={data:n,name:t,original:e};if(r){var l=r.call(i,o);!1!==l&&s.emit.apply(s,[o.name].concat(n))}else s.emit.apply(s,[t].concat(n))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,s._newListener&&s._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===o[e]&&(o[e]=l,n._on.call(i,e,l))},s.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!s.hasListeners(r)&&o[e]&&(o[e]=null,n._off.call(i,e,l))},o[e]=null,s.on("removeListener",this._onRemoveListener)):(o[e]=l,n._on.call(i,e,l))},unsubscribe:function(e){var t,r,n,i=this,s=this._listeners,o=this._emitter,l=this._off,a=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){i._onNewListener&&(o.off("newListener",i._onNewListener),o.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=j.call(o,i);o._observers.splice(e,1)}if(e){if(!(t=s[e]))return;l.call(a,e,t),delete s[e],--this._listenersCount||c()}else{for(n=(r=h(s)).length;n-- >0;)e=r[n],l.call(a,e,s[e]);this._listeners={},this._listenersCount=0,c()}}});var w=g(["function"]),E=g(["object","function"]);function L(e,t,r){var n,i,s,o=0,l=new e((function(a,c,f){function h(){i&&(i=null),o&&(clearTimeout(o),o=0)}r=_(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof f;var u=function(e){h(),a(e)},p=function(e){h(),c(e)};n?t(u,p,f):(i=[function(e){p(e||Error("canceled"))}],t(u,p,(function(e){if(s)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),s=!0),r.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=0,l.cancel(e),c(e)}),r.timeout))}));return n||(l.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),l}function j(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function k(e,t,r,n,i){if(!r)return null;if(0===n){var s=typeof t;if("string"===s){var o,l,a=0,c=0,f=this.delimiter,u=f.length;if(-1!==(l=t.indexOf(f))){o=new Array(5);do{o[a++]=t.slice(c,l),c=l+u}while(-1!==(l=t.indexOf(f,c)));o[a++]=t.slice(c),t=o,i=a}else t=[t],i=1}else"object"===s?i=t.length:(t=[t],i=1)}var p,v,y,m,d,_,b,g=null,w=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),g=[r]):(e&&e.push.apply(e,r._listeners),g=[r]));else{if("*"===w){for(l=(_=h(r)).length;l-- >0;)"_listeners"!==(p=_[l])&&(b=k(e,t,r[p],n+1,i))&&(g?g.push.apply(g,b):g=b);return g}if("**"===w){for((d=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(g=k(e,t,r,i,i)),l=(_=h(r)).length;l-- >0;)"_listeners"!==(p=_[l])&&("*"===p||"**"===p?(r[p]._listeners&&!d&&(b=k(e,t,r[p],i,i))&&(g?g.push.apply(g,b):g=b),b=k(e,t,r[p],n,i)):b=k(e,t,r[p],p===E?n+2:n,i),b&&(g?g.push.apply(g,b):g=b));return g}r[w]&&(g=k(e,t,r[w],n+1,i))}if((v=r["*"])&&k(e,t,v,n+1,i),y=r["**"])if(n<i)for(y._listeners&&k(e,t,y,i,i),l=(_=h(y)).length;l-- >0;)"_listeners"!==(p=_[l])&&(p===E?k(e,t,y[p],n+2,i):p===w?k(e,t,y[p],n+1,i):((m={})[p]=y[p],k(e,t,{"**":m},n+1,i)));else y._listeners?k(e,t,y,i,i):y["*"]&&y["*"]._listeners&&k(e,t,y["*"],i,i);return g}function O(e,t,r){var n,i,s=0,o=0,l=this.delimiter,a=l.length;if("string"==typeof e)if(-1!==(n=e.indexOf(l))){i=new Array(5);do{i[s++]=e.slice(o,n),o=n+a}while(-1!==(n=e.indexOf(l,o)));i[s++]=e.slice(o)}else i=[e],s=1;else i=e,s=e.length;if(s>1)for(n=0;n+1<s;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,f=this.listenerTree;for(n=0;n<s;n++)if(f=f[c=i[n]]||(f[c]={}),n===s-1)return f._listeners?("function"==typeof f._listeners&&(f._listeners=[f._listeners]),r?f._listeners.unshift(t):f._listeners.push(t),!f._listeners.warned&&this._maxListeners>0&&f._listeners.length>this._maxListeners&&(f._listeners.warned=!0,v.call(this,f._listeners.length,c))):f._listeners=t,!0;return!0}function x(e,t,r,n){for(var i,s,o,l,a=h(e),c=a.length,f=e._listeners;c-- >0;)i=e[s=a[c]],o="_listeners"===s?r:r?r.concat(s):[s],l=n||"symbol"==typeof s,f&&t.push(l?o:o.join(this.delimiter)),"object"==typeof i&&x.call(this,i,t,o,l);return t}function T(e){for(var t,r,n,i=h(e),s=i.length;s-- >0;)(t=e[r=i[s]])&&(n=!0,"_listeners"===r||T(t)||delete e[r]);return n}function A(e,t,r){this.emitter=e,this.event=t,this.listener=r}function P(e,t,r){if(!0===r)s=!0;else if(!1===r)n=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var n=r.async,s=r.promisify,o=r.nextTick,a=r.objectify}if(n||o||s){var c=t,h=t._origin||t;if(o&&!l)throw Error("process.nextTick is not supported");s===i&&(s="AsyncFunction"===t.constructor.name),t=function(){var e=arguments,t=this,r=this.event;return s?o?Promise.resolve():new Promise((function(e){f(e)})).then((function(){return t.event=r,c.apply(t,e)})):(o?process.nextTick:f)((function(){t.event=r,c.apply(t,e)}))},t._async=!0,t._origin=h}return[t,a?new A(this,e,t):this]}function S(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,p.call(this,e)}A.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},S.EventEmitter2=S,S.prototype.listenTo=function(e,t,r){if("object"!=typeof e)throw TypeError("target musts be an object");var n=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var i,s=r.reducers,o=j.call(n,e);i=-1===o?new d(n,e,r):n._observers[o];for(var l,a=h(t),c=a.length,f="function"==typeof s,u=0;u<c;u++)l=a[u],i.subscribe(l,t[l]||l,f?s:s&&s[l])}return r=_(r,{on:i,off:i,reducers:i},{on:w,off:w,reducers:E}),o(t)?s(m(t)):s("string"==typeof t?m(t.split(/\s+/)):t),this},S.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,s=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),s=!0);return s},S.prototype.delimiter=".",S.prototype.setMaxListeners=function(e){e!==i&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},S.prototype.getMaxListeners=function(){return this._maxListeners},S.prototype.event="",S.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},S.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},S.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},S.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},S.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},S.prototype._many=function(e,t,r,n,i){var s=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&s.off(e,o),r.apply(this,arguments)}return o._origin=r,this._on(e,o,n,i)},S.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,a)for(n=0;n<r;n++)if("symbol"==typeof o[n]){s=!0;break}s||(o=o.join(this.delimiter))}var c,f=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=o,f){case 1:c[n].call(this,o);break;case 2:c[n].call(this,o,arguments[1]);break;case 3:c[n].call(this,o,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(l)c=[],k.call(this,c,e,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[o])){switch(this.event=o,f){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];c.apply(this,t)}return!0}c&&(c=c.slice())}if(c&&c.length){if(f>3)for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=o,f){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},S.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,a)for(i=0;i<n;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var c,f=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=o,h){case 1:f.push(this._all[i].call(this,o));break;case 2:f.push(this._all[i].call(this,o,arguments[1]));break;case 3:f.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:f.push(this._all[i].apply(this,arguments))}if(l?(c=[],k.call(this,c,e,this.listenerTree,0)):c=this._events[o],"function"==typeof c)switch(this.event=o,h){case 1:f.push(c.call(this));break;case 2:f.push(c.call(this,arguments[1]));break;case 3:f.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),s=1;s<h;s++)r[s-1]=arguments[s];f.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),h>3)for(r=new Array(h-1),s=1;s<h;s++)r[s-1]=arguments[s];for(i=0,n=c.length;i<n;i++)switch(this.event=o,h){case 1:f.push(c[i].call(this));break;case 2:f.push(c[i].call(this,arguments[1]));break;case 3:f.push(c[i].call(this,arguments[1],arguments[2]));break;default:f.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},S.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},S.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},S.prototype.onAny=function(e){return this._onAny(e,!1)},S.prototype.prependAny=function(e){return this._onAny(e,!0)},S.prototype.addListener=S.prototype.on,S.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},S.prototype._on=function(e,t,r,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||u.call(this);var s,o=this;return n!==i&&(t=(s=P.call(this,e,t,n))[0],o=s[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?(O.call(this,e,t,r),o):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,v.call(this,this._events[e].length,e))):this._events[e]=t,o)},S.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,n=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=k.call(this,null,i,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],n.push({_listeners:r})}for(var s=0;s<n.length;s++){var l=n[s];if(r=l._listeners,o(r)){for(var a=-1,c=0,f=r.length;c<f;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){a=c;break}if(a<0)continue;return this.wildcard?l._listeners.splice(a,1):this._events[e].splice(a,1),0===r.length&&(this.wildcard?delete l._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete l._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&T(this.listenerTree),this},S.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},S.prototype.removeListener=S.prototype.off,S.prototype.removeAllListeners=function(e){if(e===i)return!this._events||u.call(this),this;if(this.wildcard){var t,r=k.call(this,null,e,this.listenerTree,0);if(!r)return this;for(t=0;t<r.length;t++)r[t]._listeners=null;this.listenerTree&&T(this.listenerTree)}else this._events&&(this._events[e]=null);return this},S.prototype.listeners=function(e){var t,r,n,s,o,l=this._events;if(e===i){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!l)return[];for(s=(t=h(l)).length,n=[];s-- >0;)"function"==typeof(r=l[t[s]])?n.push(r):n.push.apply(n,r);return n}if(this.wildcard){if(!(o=this.listenerTree))return[];var a=[],c="string"==typeof e?e.split(this.delimiter):e.slice();return k.call(this,a,c,o,0),a}return l&&(r=l[e])?"function"==typeof r?[r]:r:[]},S.prototype.eventNames=function(e){var t=this._events;return this.wildcard?x.call(this,this.listenerTree,[],null,e):t?h(t):[]},S.prototype.listenerCount=function(e){return this.listeners(e).length},S.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return k.call(this,t,r,this.listenerTree,0),t.length>0}var n=this._events,s=this._all;return!!(s&&s.length||n&&(e===i?h(n).length:n[e]))},S.prototype.listenersAny=function(){return this._all?this._all:[]},S.prototype.waitFor=function(e,t){var r=this,n=typeof t;return"number"===n?t={timeout:t}:"function"===n&&(t={filter:t}),L((t=_(t,{timeout:0,filter:i,handleError:!1,Promise,overload:!1},{filter:w,Promise:b})).Promise,(function(n,i,s){function o(){var s=t.filter;if(!s||s.apply(r,arguments))if(r.off(e,o),t.handleError){var l=arguments[0];l?i(l):n(y.apply(null,arguments).slice(1))}else n(y.apply(null,arguments))}s((function(){r.off(e,o)})),r._on(e,o,!1)}),{timeout:t.timeout,overload:t.overload})};var M=S.prototype;Object.defineProperties(S,{defaultMaxListeners:{get:function(){return M._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");M._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return L((r=_(r,{Promise,timeout:0,overload:!1},{Promise:b})).Promise,(function(r,n,i){var s;if("function"==typeof e.addEventListener)return s=function(){r(y.apply(null,arguments))},i((function(){e.removeEventListener(t,s)})),void e.addEventListener(t,s,{once:!0});var o,l=function(){o&&e.removeListener("error",o),r(y.apply(null,arguments))};"error"!==t&&(o=function(r){e.removeListener(t,l),n(r)},e.once("error",o)),i((function(){o&&e.removeListener("error",o),e.removeListener(t,l)})),e.once(t,l)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(M,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),(n=function(){return S}.call(t,r,t,e))===i||(e.exports=n)}()},803:t=>{"use strict";t.exports=e},810:e=>{"use strict";e.exports=t}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return r[e](s,s.exports,i),s.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{"use strict";i.r(s),i.d(s,{EventEmitterModule:()=>h,EventEmitterService:()=>f,OnAny:()=>t,OnEvent:()=>r});var e=i(803);function t(){return(t,r)=>{const n={onAny:{[r]:{}}};e.Store.from(t).merge("eventEmitter",n)}}function r(t,r){return(n,i)=>{const s={onEvent:{[i]:{event:t,options:r}}};e.Store.from(n).merge("eventEmitter",s)}}function n(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var l=i(810),a=i(124),c=i.n(a);const f=c().EventEmitter2;(0,l.registerProvider)({token:c().EventEmitter2,deps:[l.Configuration],useFactory(e){const t=e.get("eventEmitter",{enabled:!1});return t.enabled?new(c().EventEmitter2)(t):{}}});let h=class{$onInit(){this.loadEventEmitter&&this.injector.getProviders().forEach((e=>this.bindEventListeners(e)))}$onReady(){this.loadEventEmitter?(this.disableSummary||this.printEvents(),this.logger.info("EventEmitter listening...")):this.logger.info("EventEmitter disabled...")}printEvents(){const e=this.eventEmitter.eventNames().map((e=>({eventName:e,listenerCount:this.eventEmitter.listenerCount(e).toString()})));this.logger.info("EventEmitter events mounted:");const t=this.logger.drawTable(e,{padding:1,header:{eventName:"Event name",listenerCount:"Number of listener"}});this.logger.info("\n"+t.trim())}bindEventListeners(e){this.bindOn(e),this.bindOnAny(e)}getListener(e,t){const r=this.injector.get(e.token);return r[t].bind(r)}bindOn(e){const t=e.store.get("eventEmitter");Object.entries(t?.onEvent||{}).forEach((([t,{event:r,options:n}])=>{const i=this.getListener(e,t);this.eventEmitter.on(r,i,n)}))}bindOnAny(e){const t=e.store.get("eventEmitter");Object.keys(t?.onAny||{}).forEach((t=>{const r=this.getListener(e,t);this.eventEmitter.onAny(r)}))}};n([(0,l.Inject)(l.LOGGER),o("design:type",Object)],h.prototype,"logger",void 0),n([(0,l.Inject)(),o("design:type",l.InjectorService)],h.prototype,"injector",void 0),n([(0,l.Inject)(),o("design:type",f)],h.prototype,"eventEmitter",void 0),n([(0,l.Constant)("eventEmitter.disableSummary",!1),o("design:type",Boolean)],h.prototype,"disableSummary",void 0),n([(0,l.Constant)("eventEmitter.enabled",!1),o("design:type",Boolean)],h.prototype,"loadEventEmitter",void 0),h=n([(0,l.Module)()],h)})(),s})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tsed/core"),require("@tsed/di")):"function"==typeof define&&define.amd?define(["@tsed/core","@tsed/di"],t):"object"==typeof exports?exports["@tsed/event-emitter"]=t(require("@tsed/core"),require("@tsed/di")):e["@tsed/event-emitter"]=t(e["@tsed/core"],e["@tsed/di"])}(self,((e,t)=>(()=>{var r={553:(e,t,r)=>{var n;!function(i){var s=Object.hasOwnProperty,o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},l="object"==typeof process&&"function"==typeof process.nextTick,a="function"==typeof Symbol,c="object"==typeof Reflect,f="function"==typeof setImmediate?setImmediate:setTimeout,h=a?c&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function u(){this._events={},this._conf&&p.call(this,this._conf)}function p(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==i&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function v(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var y=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function m(e,t){for(var r={},n=e.length,s=t?t.length:0,o=0;o<n;o++)r[e[o]]=o<s?t[o]:i;return r}function d(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var s=e._observers;s?s.push(this):e._observers=[this]}function _(e,t,r,n){var o=Object.assign({},t);if(!e)return o;if("object"!=typeof e)throw TypeError("options must be an object");var l,a,c,f=Object.keys(e),h=f.length;function u(e){throw Error('Invalid "'+l+'" option value'+(e?". Reason: "+e:""))}for(var p=0;p<h;p++){if(l=f[p],!n&&!s.call(t,l))throw Error('Unknown "'+l+'" option');(a=e[l])!==i&&(c=r[l],o[l]=c?c(a,u):a)}return o}function b(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function g(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var s=typeof e;if(s===n||s===i)return e;r(t)}:function(n,i){for(var s=typeof n,o=r;o-- >0;)if(s===e[o])return n;i(t)}}Object.assign(d.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,s=this._emitter,o=this._listeners,l=function(){var n=y.apply(null,arguments),o={data:n,name:t,original:e};r?!1!==r.call(i,o)&&s.emit.apply(s,[o.name].concat(n)):s.emit.apply(s,[t].concat(n))};if(o[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,s._newListener&&s._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===o[e]&&(o[e]=l,n._on.call(i,e,l))},s.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!s.hasListeners(r)&&o[e]&&(o[e]=null,n._off.call(i,e,l))},o[e]=null,s.on("removeListener",this._onRemoveListener)):(o[e]=l,n._on.call(i,e,l))},unsubscribe:function(e){var t,r,n,i=this,s=this._listeners,o=this._emitter,l=this._off,a=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function c(){i._onNewListener&&(o.off("newListener",i._onNewListener),o.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=j.call(o,i);o._observers.splice(e,1)}if(e){if(!(t=s[e]))return;l.call(a,e,t),delete s[e],--this._listenersCount||c()}else{for(n=(r=h(s)).length;n-- >0;)e=r[n],l.call(a,e,s[e]);this._listeners={},this._listenersCount=0,c()}}});var w=g(["function"]),E=g(["object","function"]);function L(e,t,r){var n,i,s,o=0,l=new e((function(a,c,f){function h(){i&&(i=null),o&&(clearTimeout(o),o=0)}r=_(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof f;var u=function(e){h(),a(e)},p=function(e){h(),c(e)};n?t(u,p,f):(i=[function(e){p(e||Error("canceled"))}],t(u,p,(function(e){if(s)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),s=!0),r.timeout>0&&(o=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",o=0,l.cancel(e),c(e)}),r.timeout))}));return n||(l.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),l}function j(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function k(e,t,r,n,i){if(!r)return null;if(0===n){var s=typeof t;if("string"===s){var o,l,a=0,c=0,f=this.delimiter,u=f.length;if(-1!==(l=t.indexOf(f))){o=new Array(5);do{o[a++]=t.slice(c,l),c=l+u}while(-1!==(l=t.indexOf(f,c)));o[a++]=t.slice(c),t=o,i=a}else t=[t],i=1}else"object"===s?i=t.length:(t=[t],i=1)}var p,v,y,m,d,_,b,g=null,w=t[n],E=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),g=[r]):(e&&e.push.apply(e,r._listeners),g=[r]));else{if("*"===w){for(l=(_=h(r)).length;l-- >0;)"_listeners"!==(p=_[l])&&(b=k(e,t,r[p],n+1,i))&&(g?g.push.apply(g,b):g=b);return g}if("**"===w){for((d=n+1===i||n+2===i&&"*"===E)&&r._listeners&&(g=k(e,t,r,i,i)),l=(_=h(r)).length;l-- >0;)"_listeners"!==(p=_[l])&&("*"===p||"**"===p?(r[p]._listeners&&!d&&(b=k(e,t,r[p],i,i))&&(g?g.push.apply(g,b):g=b),b=k(e,t,r[p],n,i)):b=k(e,t,r[p],p===E?n+2:n,i),b&&(g?g.push.apply(g,b):g=b));return g}r[w]&&(g=k(e,t,r[w],n+1,i))}if((v=r["*"])&&k(e,t,v,n+1,i),y=r["**"])if(n<i)for(y._listeners&&k(e,t,y,i,i),l=(_=h(y)).length;l-- >0;)"_listeners"!==(p=_[l])&&(p===E?k(e,t,y[p],n+2,i):p===w?k(e,t,y[p],n+1,i):((m={})[p]=y[p],k(e,t,{"**":m},n+1,i)));else y._listeners?k(e,t,y,i,i):y["*"]&&y["*"]._listeners&&k(e,t,y["*"],i,i);return g}function O(e,t,r){var n,i,s=0,o=0,l=this.delimiter,a=l.length;if("string"==typeof e)if(-1!==(n=e.indexOf(l))){i=new Array(5);do{i[s++]=e.slice(o,n),o=n+a}while(-1!==(n=e.indexOf(l,o)));i[s++]=e.slice(o)}else i=[e],s=1;else i=e,s=e.length;if(s>1)for(n=0;n+1<s;n++)if("**"===i[n]&&"**"===i[n+1])return;var c,f=this.listenerTree;for(n=0;n<s;n++)if(f=f[c=i[n]]||(f[c]={}),n===s-1)return f._listeners?("function"==typeof f._listeners&&(f._listeners=[f._listeners]),r?f._listeners.unshift(t):f._listeners.push(t),!f._listeners.warned&&this._maxListeners>0&&f._listeners.length>this._maxListeners&&(f._listeners.warned=!0,v.call(this,f._listeners.length,c))):f._listeners=t,!0;return!0}function x(e,t,r,n){for(var i,s,o,l,a=h(e),c=a.length,f=e._listeners;c-- >0;)i=e[s=a[c]],o="_listeners"===s?r:r?r.concat(s):[s],l=n||"symbol"==typeof s,f&&t.push(l?o:o.join(this.delimiter)),"object"==typeof i&&x.call(this,i,t,o,l);return t}function T(e){for(var t,r,n,i=h(e),s=i.length;s-- >0;)(t=e[r=i[s]])&&(n=!0,"_listeners"===r||T(t)||delete e[r]);return n}function A(e,t,r){this.emitter=e,this.event=t,this.listener=r}function P(e,t,r){if(!0===r)s=!0;else if(!1===r)n=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var n=r.async,s=r.promisify,o=r.nextTick,a=r.objectify}if(n||o||s){var c=t,h=t._origin||t;if(o&&!l)throw Error("process.nextTick is not supported");s===i&&(s="AsyncFunction"===t.constructor.name),t=function(){var e=arguments,t=this,r=this.event;return s?o?Promise.resolve():new Promise((function(e){f(e)})).then((function(){return t.event=r,c.apply(t,e)})):(o?process.nextTick:f)((function(){t.event=r,c.apply(t,e)}))},t._async=!0,t._origin=h}return[t,a?new A(this,e,t):this]}function S(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,p.call(this,e)}A.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},S.EventEmitter2=S,S.prototype.listenTo=function(e,t,r){if("object"!=typeof e)throw TypeError("target musts be an object");var n=this;function s(t){if("object"!=typeof t)throw TypeError("events must be an object");var i,s=r.reducers,o=j.call(n,e);i=-1===o?new d(n,e,r):n._observers[o];for(var l,a=h(t),c=a.length,f="function"==typeof s,u=0;u<c;u++)l=a[u],i.subscribe(l,t[l]||l,f?s:s&&s[l])}return r=_(r,{on:i,off:i,reducers:i},{on:w,off:w,reducers:E}),o(t)?s(m(t)):s("string"==typeof t?m(t.split(/\s+/)):t),this},S.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,s=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),s=!0);return s},S.prototype.delimiter=".",S.prototype.setMaxListeners=function(e){e!==i&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},S.prototype.getMaxListeners=function(){return this._maxListeners},S.prototype.event="",S.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},S.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},S.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},S.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},S.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},S.prototype._many=function(e,t,r,n,i){var s=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function o(){return 0==--t&&s.off(e,o),r.apply(this,arguments)}return o._origin=r,this._on(e,o,n,i)},S.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(r=o.length,a)for(n=0;n<r;n++)if("symbol"==typeof o[n]){s=!0;break}s||(o=o.join(this.delimiter))}var c,f=arguments.length;if(this._all&&this._all.length)for(n=0,r=(c=this._all.slice()).length;n<r;n++)switch(this.event=o,f){case 1:c[n].call(this,o);break;case 2:c[n].call(this,o,arguments[1]);break;case 3:c[n].call(this,o,arguments[1],arguments[2]);break;default:c[n].apply(this,arguments)}if(l)c=[],k.call(this,c,e,this.listenerTree,0,r);else{if("function"==typeof(c=this._events[o])){switch(this.event=o,f){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];c.apply(this,t)}return!0}c&&(c=c.slice())}if(c&&c.length){if(f>3)for(t=new Array(f-1),i=1;i<f;i++)t[i-1]=arguments[i];for(n=0,r=c.length;n<r;n++)switch(this.event=o,f){case 1:c[n].call(this);break;case 2:c[n].call(this,arguments[1]);break;case 3:c[n].call(this,arguments[1],arguments[2]);break;default:c[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===o)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},S.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||u.call(this);var e,t,r,n,i,s,o=arguments[0],l=this.wildcard;if("newListener"===o&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=o,"newListener"!==o&&"removeListener"!==o&&"object"==typeof o)){if(n=o.length,a)for(i=0;i<n;i++)if("symbol"==typeof o[i]){t=!0;break}t||(o=o.join(this.delimiter))}var c,f=[],h=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=o,h){case 1:f.push(this._all[i].call(this,o));break;case 2:f.push(this._all[i].call(this,o,arguments[1]));break;case 3:f.push(this._all[i].call(this,o,arguments[1],arguments[2]));break;default:f.push(this._all[i].apply(this,arguments))}if(l?(c=[],k.call(this,c,e,this.listenerTree,0)):c=this._events[o],"function"==typeof c)switch(this.event=o,h){case 1:f.push(c.call(this));break;case 2:f.push(c.call(this,arguments[1]));break;case 3:f.push(c.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(h-1),s=1;s<h;s++)r[s-1]=arguments[s];f.push(c.apply(this,r))}else if(c&&c.length){if(c=c.slice(),h>3)for(r=new Array(h-1),s=1;s<h;s++)r[s-1]=arguments[s];for(i=0,n=c.length;i<n;i++)switch(this.event=o,h){case 1:f.push(c[i].call(this));break;case 2:f.push(c[i].call(this,arguments[1]));break;case 3:f.push(c[i].call(this,arguments[1],arguments[2]));break;default:f.push(c[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===o)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(f)},S.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},S.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},S.prototype.onAny=function(e){return this._onAny(e,!1)},S.prototype.prependAny=function(e){return this._onAny(e,!0)},S.prototype.addListener=S.prototype.on,S.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},S.prototype._on=function(e,t,r,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||u.call(this);var s,o=this;return n!==i&&(t=(s=P.call(this,e,t,n))[0],o=s[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?(O.call(this,e,t,r),o):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,v.call(this,this._events[e].length,e))):this._events[e]=t,o)},S.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,n=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=k.call(this,null,i,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],n.push({_listeners:r})}for(var s=0;s<n.length;s++){var l=n[s];if(r=l._listeners,o(r)){for(var a=-1,c=0,f=r.length;c<f;c++)if(r[c]===t||r[c].listener&&r[c].listener===t||r[c]._origin&&r[c]._origin===t){a=c;break}if(a<0)continue;return this.wildcard?l._listeners.splice(a,1):this._events[e].splice(a,1),0===r.length&&(this.wildcard?delete l._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete l._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&T(this.listenerTree),this},S.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},S.prototype.removeListener=S.prototype.off,S.prototype.removeAllListeners=function(e){if(e===i)return!this._events||u.call(this),this;if(this.wildcard){var t,r=k.call(this,null,e,this.listenerTree,0);if(!r)return this;for(t=0;t<r.length;t++)r[t]._listeners=null;this.listenerTree&&T(this.listenerTree)}else this._events&&(this._events[e]=null);return this},S.prototype.listeners=function(e){var t,r,n,s,o,l=this._events;if(e===i){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!l)return[];for(s=(t=h(l)).length,n=[];s-- >0;)"function"==typeof(r=l[t[s]])?n.push(r):n.push.apply(n,r);return n}if(this.wildcard){if(!(o=this.listenerTree))return[];var a=[],c="string"==typeof e?e.split(this.delimiter):e.slice();return k.call(this,a,c,o,0),a}return l&&(r=l[e])?"function"==typeof r?[r]:r:[]},S.prototype.eventNames=function(e){var t=this._events;return this.wildcard?x.call(this,this.listenerTree,[],null,e):t?h(t):[]},S.prototype.listenerCount=function(e){return this.listeners(e).length},S.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return k.call(this,t,r,this.listenerTree,0),t.length>0}var n=this._events,s=this._all;return!!(s&&s.length||n&&(e===i?h(n).length:n[e]))},S.prototype.listenersAny=function(){return this._all?this._all:[]},S.prototype.waitFor=function(e,t){var r=this,n=typeof t;return"number"===n?t={timeout:t}:"function"===n&&(t={filter:t}),L((t=_(t,{timeout:0,filter:i,handleError:!1,Promise,overload:!1},{filter:w,Promise:b})).Promise,(function(n,i,s){function o(){var s=t.filter;if(!s||s.apply(r,arguments))if(r.off(e,o),t.handleError){var l=arguments[0];l?i(l):n(y.apply(null,arguments).slice(1))}else n(y.apply(null,arguments))}s((function(){r.off(e,o)})),r._on(e,o,!1)}),{timeout:t.timeout,overload:t.overload})};var M=S.prototype;Object.defineProperties(S,{defaultMaxListeners:{get:function(){return M._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");M._maxListeners=e},enumerable:!0},once:{value:function(e,t,r){return L((r=_(r,{Promise,timeout:0,overload:!1},{Promise:b})).Promise,(function(r,n,i){var s;if("function"==typeof e.addEventListener)return s=function(){r(y.apply(null,arguments))},i((function(){e.removeEventListener(t,s)})),void e.addEventListener(t,s,{once:!0});var o,l=function(){o&&e.removeListener("error",o),r(y.apply(null,arguments))};"error"!==t&&(o=function(r){e.removeListener(t,l),n(r)},e.once("error",o)),i((function(){o&&e.removeListener("error",o),e.removeListener(t,l)})),e.once(t,l)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(M,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),(n=function(){return S}.call(t,r,t,e))===i||(e.exports=n)}()},414:t=>{"use strict";t.exports=e},546:e=>{"use strict";e.exports=t}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var s=n[e]={exports:{}};return r[e](s,s.exports,i),s.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{"use strict";i.r(s),i.d(s,{EventEmitterModule:()=>h,EventEmitterService:()=>f,OnAny:()=>t,OnEvent:()=>r});var e=i(414);function t(){return(t,r)=>{const n={onAny:{[r]:{}}};e.Store.from(t).merge("eventEmitter",n)}}function r(t,r){return(n,i)=>{const s={onEvent:{[i]:{event:t,options:r}}};e.Store.from(n).merge("eventEmitter",s)}}function n(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var l=i(546),a=i(553),c=i.n(a);const f=c().EventEmitter2;(0,l.registerProvider)({token:c().EventEmitter2,deps:[l.Configuration],useFactory(e){const t=e.get("eventEmitter",{enabled:!1});return t.enabled?new(c().EventEmitter2)(t):{}}});let h=class{$onInit(){this.loadEventEmitter&&this.injector.getProviders().forEach((e=>this.bindEventListeners(e)))}$onReady(){this.loadEventEmitter?(this.disableSummary||this.printEvents(),this.logger.info("EventEmitter listening...")):this.logger.info("EventEmitter disabled...")}printEvents(){const e=this.eventEmitter.eventNames().map((e=>({eventName:e,listenerCount:this.eventEmitter.listenerCount(e).toString()})));this.logger.info("EventEmitter events mounted:");const t=this.logger.drawTable(e,{padding:1,header:{eventName:"Event name",listenerCount:"Number of listener"}});this.logger.info("\n"+t.trim())}bindEventListeners(e){this.bindOn(e),this.bindOnAny(e)}getListener(e,t){const r=this.injector.get(e.token);return r[t].bind(r)}bindOn(e){const t=e.store.get("eventEmitter");Object.entries(t?.onEvent||{}).forEach((([t,{event:r,options:n}])=>{const i=this.getListener(e,t);this.eventEmitter.on(r,i,n)}))}bindOnAny(e){const t=e.store.get("eventEmitter");Object.keys(t?.onAny||{}).forEach((t=>{const r=this.getListener(e,t);this.eventEmitter.onAny(r)}))}};n([(0,l.Inject)(l.LOGGER),o("design:type",Object)],h.prototype,"logger",void 0),n([(0,l.Inject)(),o("design:type",l.InjectorService)],h.prototype,"injector",void 0),n([(0,l.Inject)(),o("design:type",f)],h.prototype,"eventEmitter",void 0),n([(0,l.Constant)("eventEmitter.disableSummary",!1),o("design:type",Boolean)],h.prototype,"disableSummary",void 0),n([(0,l.Constant)("eventEmitter.enabled",!1),o("design:type",Boolean)],h.prototype,"loadEventEmitter",void 0),h=n([(0,l.Module)()],h)})(),s})()));
//# sourceMappingURL=event-emitter.umd.min.js.map

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "8.3.4",
"version": "8.3.5",
"source": "./src/index.ts",

@@ -33,7 +33,7 @@ "main": "./lib/esm/index.js",

"devDependencies": {
"@tsed/barrels": "8.3.4",
"@tsed/core": "8.3.4",
"@tsed/di": "8.3.4",
"@tsed/platform-http": "8.3.4",
"@tsed/typescript": "8.3.4",
"@tsed/barrels": "8.3.5",
"@tsed/core": "8.3.5",
"@tsed/di": "8.3.5",
"@tsed/platform-http": "8.3.5",
"@tsed/typescript": "8.3.5",
"eslint": "9.12.0",

@@ -40,0 +40,0 @@ "eventemitter2": "^6.4.9",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc