-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathevent_emitter.min.js
1 lines (1 loc) · 4.32 KB
/
event_emitter.min.js
1
(function(b){function a(b,d){if({}.hasOwnProperty.call(a.cache,b))return a.cache[b];var e=a.resolve(b);if(!e)throw new Error('Failed to resolve module '+b);var c={id:b,require:a,filename:b,exports:{},loaded:!1,parent:d,children:[]};d&&d.children.push(c);var f=b.slice(0,b.lastIndexOf('/')+1);return a.cache[b]=c.exports,e.call(c.exports,c,c.exports,f,b),c.loaded=!0,a.cache[b]=c.exports}a.modules={},a.cache={},a.resolve=function(b){return{}.hasOwnProperty.call(a.modules,b)?a.modules[b]:void 0},a.define=function(b,c){a.modules[b]=c},a.define('/index.js',function(c,d,e,f){function b(){b.init.call(this)}var a={};a.isObject=function a(b){return typeof b==='object'&&b!==null},a.isNumber=function a(b){return typeof b==='number'},a.isUndefined=function a(b){return b===void 0},a.isFunction=function a(b){return typeof b==='function'},c.exports=b,b.EventEmitter=b,b.prototype._events=undefined,b.prototype._maxListeners=undefined,b.defaultMaxListeners=10,b.init=function(){this._events=this._events||{},this._maxListeners=this._maxListeners||undefined},b.prototype.setMaxListeners=function(b){if(!a.isNumber(b)||b<0||isNaN(b))throw TypeError('n must be a positive number');return this._maxListeners=b,this},b.prototype.emit=function(h){var f,c,d,e,b,g;if(this._events||(this._events={}),h==='error'&&!this._events.error)throw f=arguments[1],f instanceof Error?f:Error('Uncaught, unspecified "error" event.');if(c=this._events[h],a.isUndefined(c))return!1;if(a.isFunction(c))switch(arguments.length){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:d=arguments.length;e=new Array(d-1);for(b=1;b<d;b++)e[b-1]=arguments[b];c.apply(this,e)}else if(a.isObject(c)){for(d=arguments.length,e=new Array(d-1),b=1;b<d;b++)e[b-1]=arguments[b];for(g=c.slice(),d=g.length,b=0;b<d;b++)g[b].apply(this,e)}return!0},b.prototype.addListener=function(c,d){var e;if(!a.isFunction(d))throw TypeError('listener must be a function');if(this._events||(this._events={}),this._events.newListener&&this.emit('newListener',c,a.isFunction(d.listener)?d.listener:d),this._events[c]?a.isObject(this._events[c])?this._events[c].push(d):this._events[c]=[this._events[c],d]:this._events[c]=d,a.isObject(this._events[c])&&!this._events[c].warned){var e;a.isUndefined(this._maxListeners)?e=b.defaultMaxListeners:e=this._maxListeners,e&&e>0&&this._events[c].length>e&&(this._events[c].warned=!0,a.isFunction(console.error)&&console.error('(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.',this._events[c].length),a.isFunction(console.trace)&&console.trace())}return this},b.prototype.on=b.prototype.addListener,b.prototype.once=function(e,b){function c(){this.removeListener(e,c),d||(d=!0,b.apply(this,arguments))}if(!a.isFunction(b))throw TypeError('listener must be a function');var d=!1;return c.listener=b,this.on(e,c),this},b.prototype.removeListener=function(d,c){var b,f,g,e;if(!a.isFunction(c))throw TypeError('listener must be a function');if(!(this._events&&this._events[d]))return this;if(b=this._events[d],g=b.length,f=-1,b===c||a.isFunction(b.listener)&&b.listener===c)delete this._events[d],this._events.removeListener&&this.emit('removeListener',d,c);else if(a.isObject(b)){for(e=g;e-->0;)if(b[e]===c||b[e].listener&&b[e].listener===c){f=e;break}if(f<0)return this;b.length===1?(b.length=0,delete this._events[d]):b.splice(f,1),this._events.removeListener&&this.emit('removeListener',d,c)}return this},b.prototype.removeAllListeners=function(c){var d,b;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[c]&&delete this._events[c],this;if(arguments.length===0){for(d in this._events){if(d==='removeListener')continue;this.removeAllListeners(d)}return this.removeAllListeners('removeListener'),this._events={},this}if(b=this._events[c],a.isFunction(b))this.removeListener(c,b);else if(Array.isArray(b))while(b.length)this.removeListener(c,b[b.length-1]);return delete this._events[c],this},b.prototype.listeners=function(b){var c;return this._events&&this._events[b]?a.isFunction(this._events[b])?c=[this._events[b]]:c=this._events[b].slice():c=[],c},b.listenerCount=function(b,d){var c;return b._events&&b._events[d]?a.isFunction(b._events[d])?c=1:c=b._events[d].length:c=0,c}}),b.EventEmitter=a('/index.js')}.call(this,this))