UNPKG

bower

Version:

The browser package manager

30 lines (27 loc) 23.8 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.RpcBuilder = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ function Mapper(){var r={};this.forEach=function(e){for(var i in r){var t=r[i];for(var o in t)e(t[o])}},this.get=function(e,i){var t=r[i];if(void 0!=t)return t[e]},this.remove=function(e,i){var t=r[i];if(void 0!=t){delete t[e];for(var o in t)return!1;delete r[i]}},this.set=function(e,i,t){if(void 0==e)return this.remove(i,t);var o=r[t];void 0==o&&(r[t]=o={}),o[i]=e}}Mapper.prototype.pop=function(r,e){var i=this.get(r,e);if(void 0!=i)return this.remove(r,e),i},module.exports=Mapper; },{}],2:[function(require,module,exports){ var JsonRpcClient=require("./jsonrpcclient");exports.JsonRpcClient=JsonRpcClient; },{"./jsonrpcclient":3}],3:[function(require,module,exports){ function JsonRpcClient(e){function n(){Logger.debug("notReconnectIfNumLessThan = "+c+" (old="+s+")"),s=c}function r(){if(u){var r=null;0!=c&&c!=s||(r={interval:e.heartbeat||PING_INTERVAL}),c++,i.send("ping",r,function(e){return function(r,o){r&&(Logger.debug("Error in ping request #"+e+" ("+r.message+")"),e>s&&(u=!1,n(),Logger.debug("Server did not respond to ping message #"+e+". Reconnecting... "),O.reconnectWs()))}}(c))}else Logger.debug("Trying to send ping, but ping is not enabled")}function o(){N||(Logger.debug("Starting ping (if configured)"),N=!0,void 0!=e.heartbeat&&(t=setInterval(r,e.heartbeat),r()))}var t,i=this,g=e.ws,s=-1,c=0,u=!0,N=!1,a=DISCONNECTED,d=g.onreconnecting,C=g.onreconnected,E=g.onconnected,l=g.onerror;e.rpc.pull=function(e,n){n.reply(null,"push")},g.onreconnecting=function(){if(Logger.debug("--------- ONRECONNECTING -----------"),a===RECONNECTING)return void Logger.error("Websocket already in RECONNECTING state when receiving a new ONRECONNECTING message. Ignoring it");a=RECONNECTING,d&&d()},g.onreconnected=function(){if(Logger.debug("--------- ONRECONNECTED -----------"),a===CONNECTED)return void Logger.error("Websocket already in CONNECTED state when receiving a new ONRECONNECTED message. Ignoring it");a=CONNECTED,u=!0,n(),o(),C&&C()},g.onconnected=function(){if(Logger.debug("--------- ONCONNECTED -----------"),a===CONNECTED)return void Logger.error("Websocket already in CONNECTED state when receiving a new ONCONNECTED message. Ignoring it");a=CONNECTED,u=!0,o(),E&&E()},g.onerror=function(e){Logger.debug("--------- ONERROR -----------"),a=DISCONNECTED,l&&l(e)};var O=new WebSocketWithReconnection(g);Logger.debug("Connecting websocket to URI: "+g.uri);var R={request_timeout:e.rpc.requestTimeout,ping_request_timeout:e.rpc.heartbeatRequestTimeout},f=new RpcBuilder(RpcBuilder.packers.JsonRPC,R,O,function(n){Logger.debug("Received request: "+JSON.stringify(n));try{var r=e.rpc[n.method];void 0===r?Logger.error("Method "+n.method+" not registered in client"):r(n.params,n)}catch(e){Logger.error("Exception processing request: "+JSON.stringify(n)),Logger.error(e)}});this.send=function(e,n,r){"ping"!==e&&Logger.debug("Request: method:"+e+" params:"+JSON.stringify(n));var o=Date.now();f.encode(e,n,function(t,i){if(t){try{Logger.error("ERROR:"+t.message+" in Request: method:"+e+" params:"+JSON.stringify(n)+" request:"+t.request),t.data&&Logger.error("ERROR DATA:"+JSON.stringify(t.data))}catch(e){}t.requestTime=o}r&&(void 0!=i&&"pong"!==i.value&&Logger.debug("Response: "+JSON.stringify(i)),r(t,i))})},this.close=function(){Logger.debug("Closing jsonRpcClient explicitly by client"),void 0!=t&&(Logger.debug("Clearing ping interval"),clearInterval(t)),N=!1,u=!1,e.sendCloseMessage?(Logger.debug("Sending close message"),this.send("closeSession",null,function(e,n){e&&Logger.error("Error sending close message: "+JSON.stringify(e)),O.close()})):O.close()},this.forceClose=function(e){O.forceClose(e)},this.reconnect=function(){O.reconnectWs()}}var RpcBuilder=require("../.."),WebSocketWithReconnection=require("./transports/webSocketWithReconnection");Date.now=Date.now||function(){return+new Date};var PING_INTERVAL=5e3,RECONNECTING="RECONNECTING",CONNECTED="CONNECTED",DISCONNECTED="DISCONNECTED",Logger=console;module.exports=JsonRpcClient; },{"../..":6,"./transports/webSocketWithReconnection":5}],4:[function(require,module,exports){ var WebSocketWithReconnection=require("./webSocketWithReconnection");exports.WebSocketWithReconnection=WebSocketWithReconnection; },{"./webSocketWithReconnection":5}],5:[function(require,module,exports){ (function (global){(function (){ "use strict";function WebSocketWithReconnection(e){function o(e,o){try{Logger.debug("WebSocket connected to "+o)}catch(e){Logger.error(e)}}function n(o,c){if(Logger.debug("reconnectToSameUri (attempt #"+c+", max="+o+")"),1===c){if(u)return void Logger.warn("Trying to reconnectToNewUri when reconnecting... Ignoring this reconnection.");u=!0,e.onreconnecting&&e.onreconnecting()}d?t(o,c,g):e.newWsUriOnReconnection?e.newWsUriOnReconnection(function(e,r){e?(Logger.debug(e),setTimeout(function(){n(o,c+1)},RETRY_TIME_MS)):t(o,c,r)}):t(o,c,g)}function t(t,i,d){Logger.debug("Reconnection attempt #"+i),r.close(),g=d||g;var b;b=s?new SockJS(g):new WebSocket(g),b.onopen=function(){Logger.debug("Reconnected after "+i+" attempts..."),o(b,g),u=!1,c(),e.onreconnected()&&e.onreconnected(),b.onclose=f};var S=function(o){Logger.warn("Reconnection error: ",o),i===t?e.ondisconnect&&e.ondisconnect():setTimeout(function(){n(t,i+1)},RETRY_TIME_MS)};b.onerror=S,r=b}var c,r,i=!1,g=e.uri,s=e.useSockJS,u=!1,d=!1;r=s?new SockJS(g):new WebSocket(g),r.onopen=function(){o(r,g),e.onconnected&&e.onconnected()},r.onerror=function(o){Logger.error("Could not connect to "+g+" (invoking onerror if defined)",o),e.onerror&&e.onerror(o)};var f=function(){r.readyState===CLOSED?i?Logger.debug("Connection closed by user"):(Logger.debug("Connection closed unexpectecly. Reconnecting..."),n(MAX_RETRIES,1)):Logger.debug("Close callback from previous websocket. Ignoring it")};r.onclose=f,this.close=function(){i=!0,r.close()},this.forceClose=function(e){if(Logger.debug("Testing: Force WebSocket close"),e){Logger.debug("Testing: Change wsUri for "+e+" millis to simulate net failure");var o=g;g="wss://21.234.12.34.4:443/",d=!0,setTimeout(function(){Logger.debug("Testing: Recover good wsUri "+o),g=o,d=!1},e)}r.close()},this.reconnectWs=function(){Logger.debug("reconnectWs"),n(MAX_RETRIES,1,g)},this.send=function(e){r.send(e)},this.addEventListener=function(e,o){(c=function(){r.addEventListener(e,o)})()}}var BrowserWebSocket=global.WebSocket||global.MozWebSocket,Logger=console,WebSocket=BrowserWebSocket;if(!WebSocket&&"undefined"==typeof window)try{WebSocket=require("ws")}catch(e){}var MAX_RETRIES=2e3,RETRY_TIME_MS=3e3,CONNECTING=0,OPEN=1,CLOSING=2,CLOSED=3;module.exports=WebSocketWithReconnection; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"ws":undefined}],6:[function(require,module,exports){ function unifyResponseMethods(e){if(!e)return{};for(var t in e){var r=e[t];"string"==typeof r&&(e[t]={response:r})}return e}function unifyTransport(e){if(e){if(e instanceof Function)return{send:e};if(e.send instanceof Function)return e;if(e.postMessage instanceof Function)return e.send=e.postMessage,e;if(e.write instanceof Function)return e.send=e.write,e;if(void 0===e.onmessage&&!(e.pause instanceof Function))throw new SyntaxError("Transport is not a function nor a valid object")}}function RpcNotification(e,t){defineProperty_IE8?(this.method=e,this.params=t):(Object.defineProperty(this,"method",{value:e,enumerable:!0}),Object.defineProperty(this,"params",{value:t,enumerable:!0}))}function RpcBuilder(e,t,r,n){function i(e){p.decode(e.data||e.toString())}function o(e,t,r){var n={message:e,timeout:setTimeout(function(){T.remove(t,r)},v)};T.set(n,t,r)}function s(e,t){var r=setTimeout(function(){E.remove(e,t)},h);E.set(r,e,t)}function a(t,r,n,i,s){RpcNotification.call(this,t,r),this.getTransport=function(){return s},this.setTransport=function(e){s=unifyTransport(e)},defineProperty_IE8||Object.defineProperty(this,"transport",{get:this.getTransport.bind(this),set:this.setTransport.bind(this)});var a=T.get(n,i);s||p.getTransport()||(defineProperty_IE8?this.duplicated=Boolean(a):Object.defineProperty(this,"duplicated",{value:Boolean(a)}));var c=f[t];this.pack=e.pack.bind(e,this,n),this.reply=function(t,r,s){if(t instanceof Function||t&&t.send instanceof Function){if(void 0!=r)throw new SyntaxError("There can't be parameters after callback");s=t,r=null,t=void 0}else if(r instanceof Function||r&&r.send instanceof Function){if(void 0!=s)throw new SyntaxError("There can't be parameters after callback");s=r,r=null}s=unifyTransport(s),a&&clearTimeout(a.timeout),void 0!=i&&(t&&(t.dest=i),r&&(r.dest=i));var f;if(t||void 0!=r){if(void 0!=p.peerID&&(t?t.from=p.peerID:r.from=p.peerID),c)if(void 0==c.error&&t)f={error:t};else{var u=t?c.error:c.response;f={method:u,params:t||r}}else f={error:t,result:r};f=e.pack(f,n)}else f=a?a.message:e.pack({result:null},n);return o(f,n,i),s=s||this.getTransport()||p.getTransport(),s?s.send(f):f}}function c(e){var t=w[e];if(t){delete w[e];var r=y.pop(t.id,t.dest);r&&(clearTimeout(r.timeout),s(t.id,t.dest))}}var p=this;if(!e)throw new SyntaxError("Packer is not defined");if(!e.pack||!e.unpack)throw new SyntaxError("Packer is invalid");var f=unifyResponseMethods(e.responseMethods);if(t instanceof Function){if(void 0!=r)throw new SyntaxError("There can't be parameters after onRequest");n=t,r=void 0,t=void 0}if(t&&t.send instanceof Function){if(r&&!(r instanceof Function))throw new SyntaxError("Only a function can be after transport");n=r,r=t,t=void 0}if(r instanceof Function){if(void 0!=n)throw new SyntaxError("There can't be parameters after onRequest");n=r,r=void 0}if(r&&r.send instanceof Function&&n&&!(n instanceof Function))throw new SyntaxError("Only a function can be after transport");t=t||{},EventEmitter.call(this),n&&this.on("request",n),defineProperty_IE8?this.peerID=t.peerID:Object.defineProperty(this,"peerID",{value:t.peerID});var u=t.max_retries||0;this.getTransport=function(){return r},this.setTransport=function(e){r&&(r.removeEventListener?r.removeEventListener("message",i):r.removeListener&&r.removeListener("data",i)),e&&(e.addEventListener?e.addEventListener("message",i):e.addListener&&e.addListener("data",i)),r=unifyTransport(e)},defineProperty_IE8||Object.defineProperty(this,"transport",{get:this.getTransport.bind(this),set:this.setTransport.bind(this)}),this.setTransport(r);var d=t.request_timeout||BASE_TIMEOUT,l=t.ping_request_timeout||d,v=t.response_timeout||BASE_TIMEOUT,h=t.duplicates_timeout||BASE_TIMEOUT,m=0,y=new Mapper,T=new Mapper,E=new Mapper,w={};inherits(a,RpcNotification),this.cancel=function(e){if(e)return c(e);for(var e in w)c(e)},this.close=function(){var e=this.getTransport();e&&e.close&&e.close(),this.cancel(),E.forEach(clearTimeout),T.forEach(function(e){clearTimeout(e.timeout)})},this.encode=function(t,r,n,i,o){function s(e,t){p.cancel(h),o(e,t)}function a(e){var r="ping"===t?l:d;return g.timeout=setTimeout(v,r*Math.pow(2,b++)),w[h]={id:T,dest:n},y.set(g,T,n),e=e||I||p.getTransport(),e?e.send(h):h}function c(e){e=unifyTransport(e),console.warn(b+" retry for request message:",h);var t=E.pop(T,n);return clearTimeout(t),a(e)}function v(){if(b<u)return c(i);var e=new Error("Request has timed out");e.request=h,e.retry=c,s(e)}if(r instanceof Function){if(void 0!=n)throw new SyntaxError("There can't be parameters after callback");o=r,i=void 0,n=void 0,r=void 0}else if(n instanceof Function){if(void 0!=i)throw new SyntaxError("There can't be parameters after callback");o=n,i=void 0,n=void 0}else if(i instanceof Function){if(void 0!=o)throw new SyntaxError("There can't be parameters after callback");o=i,i=void 0}void 0!=p.peerID&&(r=r||{},r.from=p.peerID),void 0!=n&&(r=r||{},r.dest=n);var h={method:t,params:r};if(o){var T=m++,b=0;h=e.pack(h,T);var g={message:h,callback:s,responseMethods:f[t]||{}},I=unifyTransport(i);return a(i)}return h=e.pack(h),i=i||this.getTransport(),i?i.send(h):h},this.decode=function(t,r){function n(){if(r=unifyTransport(r)||p.getTransport()){var e=T.get(c,l);if(e)return r.send(e.message)}var t=void 0!=c?c:f,n=new a(u,d,t,l,r);if(!p.emit("request",n))return n}function i(e,t,r){e.callback(t,r)}function o(e){console.warn("Response already processed",t),clearTimeout(e),s(f,l)}if(!t)throw new TypeError("Message is not defined");try{t=e.unpack(t)}catch(e){return console.debug(e,t)}var c=t.id,f=t.ack,u=t.method,d=t.params||{},l=d.from,v=d.dest;if(void 0==p.peerID||l!=p.peerID){if(void 0==c&&void 0==f){var h=new RpcNotification(u,d);if(p.emit("request",h))return;return h}if(u){if(void 0==v||v==p.peerID){var m=y.get(f,l);if(m){var w=m.responseMethods;return u==w.error?i(m,d):u==w.response?i(m,null,d):n()}var b=E.get(f,l);if(b)return o(b)}return n()}var g=t.error,I=t.result;if(!(g&&g.dest&&g.dest!=p.peerID||I&&I.dest&&I.dest!=p.peerID)){var m=y.get(f,l);if(!m){var b=E.get(f,l);return b?o(b):console.warn("No callback was defined for this message",t)}i(m,g,I)}}}}var defineProperty_IE8=!1;if(Object.defineProperty)try{Object.defineProperty({},"x",{})}catch(e){defineProperty_IE8=!0}Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),r=this,n=function(){},i=function(){return r.apply(this instanceof n&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,i.prototype=new n,i});var EventEmitter=require("events").EventEmitter,inherits=require("inherits"),packers=require("./packers"),Mapper=require("./Mapper"),BASE_TIMEOUT=5e3;inherits(RpcBuilder,EventEmitter),RpcBuilder.RpcNotification=RpcNotification,module.exports=RpcBuilder;var clients=require("./clients"),transports=require("./clients/transports");RpcBuilder.clients=clients,RpcBuilder.clients.transports=transports,RpcBuilder.packers=packers; },{"./Mapper":1,"./clients":2,"./clients/transports":4,"./packers":9,"events":10,"inherits":11}],7:[function(require,module,exports){ function pack(r,e){var o={jsonrpc:"2.0"};if(r.method)o.method=r.method,r.params&&(o.params=r.params),void 0!=e&&(o.id=e);else if(void 0!=e){if(r.error){if(void 0!==r.result)throw new TypeError("Both result and error are defined");o.error=r.error}else{if(void 0===r.result)throw new TypeError("No result or error is defined");o.result=r.result}o.id=e}return JSON.stringify(o)}function unpack(r){var e=r;("string"==typeof r||r instanceof String)&&(e=JSON.parse(r));var o=e.jsonrpc;if("2.0"!==o)throw new TypeError("Invalid JsonRPC version '"+o+"': "+r);if(void 0==e.method){if(void 0==e.id)throw new TypeError("Invalid message: "+r);var i=void 0!==e.result,t=void 0!==e.error;if(i&&t)throw new TypeError("Both result and error are defined: "+r);if(!i&&!t)throw new TypeError("No result or error is defined: "+r);e.ack=e.id,delete e.id}return e}exports.pack=pack,exports.unpack=unpack; },{}],8:[function(require,module,exports){ function pack(e){throw new TypeError("Not yet implemented")}function unpack(e){throw new TypeError("Not yet implemented")}exports.pack=pack,exports.unpack=unpack; },{}],9:[function(require,module,exports){ var JsonRPC=require("./JsonRPC"),XmlRPC=require("./XmlRPC");exports.JsonRPC=JsonRPC,exports.XmlRPC=XmlRPC; },{"./JsonRPC":7,"./XmlRPC":8}],10:[function(require,module,exports){ function EventEmitter(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=objectCreate(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function $getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function emitNone(e,t,n){if(t)e.call(n);else for(var r=e.length,i=arrayClone(e,r),s=0;s<r;++s)i[s].call(n)}function emitOne(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=arrayClone(e,i),o=0;o<i;++o)s[o].call(n,r)}function emitTwo(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,o=arrayClone(e,s),a=0;a<s;++a)o[a].call(n,r,i)}function emitThree(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var o=e.length,a=arrayClone(e,o),l=0;l<o;++l)a[l].call(n,r,i,s)}function emitMany(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=arrayClone(e,i),o=0;o<i;++o)s[o].apply(n,r)}function _addListener(e,t,n,r){var i,s,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if(s=e._events,s?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]):(s=e._events=objectCreate(null),e._eventsCount=0),o){if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=$getMaxListeners(e))&&i>0&&o.length>i){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}}else o=s[t]=n,++e._eventsCount;return e}function onceWrapper(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function _onceWrap(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=bind.call(onceWrapper,r);return i.listener=n,r.wrapFn=i,i}function _listeners(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?unwrapListeners(i):arrayClone(i,i.length):[]}function listenerCount(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function spliceOne(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}function arrayClone(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function unwrapListeners(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function objectCreatePolyfill(e){var t=function(){};return t.prototype=e,new t}function objectKeysPolyfill(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n}function functionBindPolyfill(e){var t=this;return function(){return t.apply(e,arguments)}}var objectCreate=Object.create||objectCreatePolyfill,objectKeys=Object.keys||objectKeysPolyfill,bind=Function.prototype.bind||functionBindPolyfill;module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0;var defaultMaxListeners=10,hasDefineProperty;try{var o={};Object.defineProperty&&Object.defineProperty(o,"x",{value:0}),hasDefineProperty=0===o.x}catch(e){hasDefineProperty=!1}hasDefineProperty?Object.defineProperty(EventEmitter,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(e){if("number"!=typeof e||e<0||e!==e)throw new TypeError('"defaultMaxListeners" must be a positive number');defaultMaxListeners=e}}):EventEmitter.defaultMaxListeners=defaultMaxListeners,EventEmitter.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},EventEmitter.prototype.getMaxListeners=function(){return $getMaxListeners(this)},EventEmitter.prototype.emit=function(e){var t,n,r,i,s,o,a="error"===e;if(o=this._events)a=a&&null==o.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(n=o[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:emitNone(n,u,this);break;case 2:emitOne(n,u,this,arguments[1]);break;case 3:emitTwo(n,u,this,arguments[1],arguments[2]);break;case 4:emitThree(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];emitMany(n,u,this,i)}return!0},EventEmitter.prototype.addListener=function(e,t){return _addListener(this,e,t,!1)},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.prependListener=function(e,t){return _addListener(this,e,t,!0)},EventEmitter.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,_onceWrap(this,e,t)),this},EventEmitter.prototype.removeListener=function(e,t){var n,r,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=objectCreate(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():spliceOne(n,i),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,o||t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,n,r;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=objectCreate(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=objectCreate(null):delete n[e]),this;if(0===arguments.length){var i,s=objectKeys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=objectCreate(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},EventEmitter.prototype.listeners=function(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}; },{}],11:[function(require,module,exports){ "function"==typeof Object.create?module.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(t,e){if(e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}}; },{}]},{},[6])(6) }); //# sourceMappingURL=kurento-jsonrpc.map