simple-websocket
Advanced tools
Comparing version 1.3.0 to 2.0.0
211
index.js
@@ -5,104 +5,179 @@ /* global Blob */ | ||
var EventEmitter = require('events').EventEmitter | ||
var debug = require('debug')('simple-websocket') | ||
var inherits = require('inherits') | ||
var isTypedArray = require('is-typedarray') | ||
var once = require('once') | ||
var stream = require('stream') | ||
var toBuffer = require('typedarray-to-buffer') | ||
var ws = require('ws') // websockets in node - will be empty object in browser | ||
var RECONNECT_TIMEOUT = 5000 | ||
var WebSocket = typeof window !== 'undefined' ? window.WebSocket : ws | ||
inherits(Socket, EventEmitter) | ||
inherits(Socket, stream.Duplex) | ||
/** | ||
* WebSocket. Same API as node core `net.Socket`. Duplex stream. | ||
* @param {string} url websocket server url | ||
* @param {Object} opts options to stream.Duplex | ||
*/ | ||
function Socket (url, opts) { | ||
if (!(this instanceof Socket)) return new Socket(url, opts) | ||
EventEmitter.call(this) | ||
var self = this | ||
if (!(self instanceof Socket)) return new Socket(url, opts) | ||
if (!opts) opts = {} | ||
debug('new websocket %s %o', url, opts) | ||
this._url = url | ||
this._reconnect = (opts.reconnect !== undefined) | ||
? opts.reconnect | ||
: RECONNECT_TIMEOUT | ||
this.ready = false | ||
opts.allowHalfOpen = false | ||
stream.Duplex.call(self, opts) | ||
this._init() | ||
} | ||
self.url = url | ||
self.connected = false | ||
self.destroyed = false | ||
Socket.prototype.send = function (chunk) { | ||
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return | ||
self._buffer = [] | ||
if (chunk instanceof ArrayBuffer || typeof chunk === 'string' || | ||
Buffer.isBuffer(chunk) || (typeof Blob !== 'undefined' && chunk instanceof Blob)) { | ||
this._ws.send(chunk) | ||
} else if (isTypedArray.strict(chunk)) { | ||
// TODO: don't send full arraybuffer, respect the "view" on the arraybuffer | ||
this._ws.send(chunk.buffer) | ||
} else { | ||
this._ws.send(JSON.stringify(chunk)) | ||
} | ||
self._ws = new WebSocket(self.url) | ||
self._ws.binaryType = 'arraybuffer' | ||
self._ws.onopen = self._onOpen.bind(self) | ||
self._ws.onmessage = self._onMessage.bind(self) | ||
self._ws.onclose = self._onClose.bind(self) | ||
self._ws.onerror = self._onError.bind(self) | ||
self.on('finish', function () { | ||
if (self.connected) { | ||
// When stream is finished writing, close socket connection. Half open connections | ||
// are currently not supported. | ||
self._destroy() | ||
} else { | ||
// If socket is not connected when stream is finished writing, wait until data is | ||
// flushed to network at "connect" event. | ||
// TODO: is there a more reliable way to accomplish this? | ||
self.once('connect', function () { | ||
setTimeout(function () { | ||
self._destroy() | ||
}, 100) | ||
}) | ||
} | ||
}) | ||
} | ||
Socket.prototype.destroy = function (onclose) { | ||
if (onclose) this.once('close', onclose) | ||
try { | ||
this._ws.close() | ||
} catch (err) { | ||
this._onclose() | ||
} | ||
Socket.prototype.send = function (chunk, cb) { | ||
var self = this | ||
if (!cb) cb = noop | ||
self._write(chunk, undefined, cb) | ||
} | ||
Socket.prototype._init = function () { | ||
this._errored = false | ||
this._ws = new WebSocket(this._url) | ||
this._ws.binaryType = 'arraybuffer' | ||
this._ws.onopen = this._onopen.bind(this) | ||
this._ws.onmessage = this._onmessage.bind(this) | ||
this._ws.onclose = this._onclose.bind(this) | ||
this._ws.onerror = once(this._onerror.bind(this)) | ||
Socket.prototype.destroy = function (onclose) { | ||
var self = this | ||
self._destroy(null, onclose) | ||
} | ||
Socket.prototype._onopen = function () { | ||
this.ready = true | ||
this.emit('ready') | ||
Socket.prototype._destroy = function (err, onclose) { | ||
var self = this | ||
if (self.destroyed) return | ||
if (onclose) self.once('close', onclose) | ||
debug('destroy (error: %s)', err && err.message) | ||
self.connected = false | ||
self.destroyed = true | ||
if (self._ws) { | ||
try { | ||
self._ws.close() | ||
} catch (err) {} | ||
self._ws.onopen = null | ||
self._ws.onmessage = null | ||
self._ws.onclose = null | ||
self._ws.onerror = null | ||
} | ||
self._ws = null | ||
this.readable = this.writable = false | ||
if (!self._readableState.ended) self.push(null) | ||
if (!self._writableState.finished) self.end() | ||
if (err) self.emit('error', err) | ||
self.emit('close') | ||
} | ||
Socket.prototype._onerror = function (err) { | ||
this._errored = true | ||
Socket.prototype._read = function () {} | ||
// On error, close socket... | ||
this.destroy() | ||
/** | ||
* Send text/binary data to the WebSocket server. | ||
* @param {string|Buffer|TypedArrayView|ArrayBuffer|Blob} chunk | ||
* @param {string} encoding | ||
* @param {function} cb | ||
*/ | ||
Socket.prototype._write = function (chunk, encoding, cb) { | ||
var self = this | ||
if (self.destroyed) return cb(new Error('cannot write after socket is destroyed')) | ||
// ...and try to reconnect after a timeout | ||
if (this._reconnect) { | ||
this._timeout = setTimeout(this._init.bind(this), this._reconnect) | ||
this.emit('warning', err) | ||
var len = chunk.length || chunk.byteLength || chunk.size | ||
if (!self.connected) { | ||
debug('_write before ready: length %d', len) | ||
self._buffer.push(chunk) | ||
cb(null) | ||
return | ||
} | ||
debug('_write: length %d', len) | ||
if (isTypedArray.strict(chunk) || chunk instanceof ArrayBuffer || | ||
Buffer.isBuffer(chunk) || typeof chunk === 'string' || | ||
(typeof Blob !== 'undefined' && chunk instanceof Blob)) { | ||
self._ws.send(chunk) | ||
} else { | ||
this.emit('error', err) | ||
self._ws.send(JSON.stringify(chunk)) | ||
} | ||
cb(null) | ||
} | ||
Socket.prototype._onmessage = function (event) { | ||
var message = event.data | ||
if (message instanceof ArrayBuffer) { | ||
message = toBuffer(new Uint8Array(message)) | ||
Socket.prototype._onMessage = function (event) { | ||
var self = this | ||
if (self.destroyed) return | ||
var data = event.data | ||
debug('on message: length %d', data.byteLength || data.length) | ||
if (data instanceof ArrayBuffer) { | ||
data = toBuffer(new Uint8Array(data)) | ||
self.push(data) | ||
} else if (Buffer.isBuffer(data)) { | ||
self.push(data) | ||
} else { | ||
try { | ||
message = JSON.parse(message) | ||
data = JSON.parse(data) | ||
} catch (err) {} | ||
self.emit('data', data) | ||
} | ||
this.emit('message', message) | ||
} | ||
Socket.prototype._onclose = function () { | ||
clearTimeout(this._timeout) | ||
if (this._ws) { | ||
this._ws.onopen = null | ||
this._ws.onerror = null | ||
this._ws.onmessage = null | ||
this._ws.onclose = null | ||
} | ||
this._ws = null | ||
if (!this._errored) this.emit('close') | ||
Socket.prototype._onOpen = function () { | ||
var self = this | ||
if (self.connected || self.destroyed) return | ||
self.connected = true | ||
self._buffer.forEach(function (chunk) { | ||
self.send(chunk) | ||
}) | ||
self._buffer = [] | ||
debug('connect') | ||
self.emit('connect') | ||
} | ||
Socket.prototype._onClose = function () { | ||
var self = this | ||
if (self.destroyed) return | ||
debug('on close') | ||
self._destroy() | ||
} | ||
Socket.prototype._onError = function (err) { | ||
var self = this | ||
if (self.destroyed) return | ||
debug('error %s', err.message || err) | ||
self._destroy(err) | ||
} | ||
function noop () {} |
{ | ||
"name": "simple-websocket", | ||
"description": "Simple, EventEmitter API for WebSockets (browser)", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"author": { | ||
@@ -17,5 +17,5 @@ "name": "Feross Aboukhadijeh", | ||
"dependencies": { | ||
"debug": "^2.1.3", | ||
"inherits": "^2.0.1", | ||
"is-typedarray": "0.0.0", | ||
"once": "^1.3.0", | ||
"typedarray-to-buffer": "^3.0.1", | ||
@@ -27,3 +27,3 @@ "ws": "^0.7.1" | ||
"standard": "^3.3.2", | ||
"tape": "^3.0.3", | ||
"tape": "^4.0.0", | ||
"uglify-js": "^2.4.15", | ||
@@ -30,0 +30,0 @@ "zuul": "^2.1.1" |
@@ -1,1 +0,2 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SimpleWebsocket=t()}}(function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return i(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(){},{}],2:[function(t,e,r){function n(t,e){var r=this;if(!(r instanceof n))return new n(t,e);var i,o=typeof t;if("number"===o)i=+t;else if("string"===o)i=n.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&D(t.data)&&(t=t.data),i=+t.length}if(i>C)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C.toString(16)+" bytes");0>i?i=0:i>>>=0,n.TYPED_ARRAY_SUPPORT?r=n._augment(new Uint8Array(i)):(r.length=i,r._isBuffer=!0);var s;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)r._set(t);else if(U(t))if(n.isBuffer(t))for(s=0;i>s;s++)r[s]=t.readUInt8(s);else for(s=0;i>s;s++)r[s]=(t[s]%256+256)%256;else if("string"===o)r.write(t,0,e);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT)for(s=0;i>s;s++)r[s]=0;return i>0&&i<=n.poolSize&&(r.parent=k),r}function i(t,e){if(!(this instanceof i))return new i(t,e);var r=new n(t,e);return delete r.parent,r}function o(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function s(t,e,r,n){var i=x(R(e,t.length-r),t,r,n);return i}function a(t,e,r,n){var i=x(T(e),t,r,n);return i}function u(t,e,r,n){return a(t,e,r,n)}function h(t,e,r,n){var i=x(S(e),t,r,n);return i}function f(t,e,r,n){var i=x(P(e,t.length-r),t,r,n);return i}function c(t,e,r){return Y.fromByteArray(0===e&&r===t.length?t:t.slice(e,r))}function l(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=O(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+O(i)}function p(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function y(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function g(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=L(t[o]);return i}function w(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function d(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function v(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function E(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function _(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function b(t,e,r,n,i,o){if(e>i||o>e)throw new RangeError("value is out of bounds");if(r+n>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function m(t,e,r,n,i){return i||b(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),M.write(t,e,r,n,23,4),r+4}function A(t,e,r,n,i){return i||b(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),M.write(t,e,r,n,52,8),r+8}function I(t){if(t=B(t).replace(N,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function B(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function U(t){return D(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function L(t){return 16>t?"0"+t.toString(16):t.toString(16)}function R(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;n>s;s++){if(r=t.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((e-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((e-=1)<0)break;o.push(r)}else if(2048>r){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function T(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function P(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);s++)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function S(t){return Y.toByteArray(I(t))}function x(t,e,r,n){for(var i=0;n>i&&!(i+r>=e.length||i>=t.length);i++)e[i+r]=t[i];return i}function O(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}var Y=t("base64-js"),M=t("ieee754"),D=t("is-array");r.Buffer=n,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var C=1073741823,k={};n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];o++);return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(t,e){if(!D(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var i=new n(e),o=0;for(r=0;r<t.length;r++){var s=t[r];s.copy(i,o),o+=s.length}return i},n.byteLength=function(t,e){var r;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":r=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;case"hex":r=t.length>>>1;break;case"utf8":case"utf-8":r=R(t).length;break;case"base64":r=S(t).length;break;default:r=t.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return g(this,e,r);case"utf8":case"utf-8":return l(this,e,r);case"ascii":return p(this,e,r);case"binary":return y(this,e,r);case"base64":return c(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:n.compare(this,t)},n.prototype.indexOf=function(t,e){function r(t,e,r){for(var n=-1,i=0;r+i<t.length;i++)if(t[r+i]===e[-1===n?0:i-n]){if(-1===n&&(n=i),i-n+1===e.length)return r+n}else n=-1;return-1}if(e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(n.isBuffer(t))return r(this,t,e);if("number"==typeof t)return n.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var i=n;n=e,e=r,r=i}if(e=Number(e)||0,0>r||0>e||e>this.length)throw new RangeError("attempt to write outside buffer bounds");var c=this.length-e;r?(r=Number(r),r>c&&(r=c)):r=c,n=String(n||"utf8").toLowerCase();var l;switch(n){case"hex":l=o(this,t,e,r);break;case"utf8":case"utf-8":l=s(this,t,e,r);break;case"ascii":l=a(this,t,e,r);break;case"binary":l=u(this,t,e,r);break;case"base64":l=h(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(t,e));else{var o=e-t;i=new n(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+t]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},n.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},n.prototype.readUInt8=function(t,e){return e||d(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||d(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||d(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||d(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||d(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},n.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||d(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},n.prototype.readInt8=function(t,e){return e||d(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||d(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||d(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||d(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||d(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||d(t,4,this.length),M.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||d(t,4,this.length),M.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||d(t,8,this.length),M.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||d(t,8,this.length),M.read(this,t,!1,52,8)},n.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||v(this,t,e,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i>>>0&255;return e+r},n.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||v(this,t,e,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o>>>0&255;return e+r},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):_(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):_(this,t,e,!1),e+4},n.prototype.writeIntLE=function(t,e,r,n){t=+t,e>>>=0,n||v(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=0,o=1,s=0>t?1:0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=(t/o>>0)-s&255;return e+r},n.prototype.writeIntBE=function(t,e,r,n){t=+t,e>>>=0,n||v(this,t,e,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=r-1,o=1,s=0>t?1:0;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=(t/o>>0)-s&255;return e+r},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):E(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):E(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):_(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):_(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return m(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return m(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return A(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return A(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r;if(1e3>o||!n.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)t[s+e]=this[s+r];else t._set(this.subarray(r,r+o),e);return o},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=R(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var j=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._set=t.set,t.get=j.get,t.set=j.set,t.write=j.write,t.toString=j.toString,t.toLocaleString=j.toString,t.toJSON=j.toJSON,t.equals=j.equals,t.compare=j.compare,t.indexOf=j.indexOf,t.copy=j.copy,t.slice=j.slice,t.readUIntLE=j.readUIntLE,t.readUIntBE=j.readUIntBE,t.readUInt8=j.readUInt8,t.readUInt16LE=j.readUInt16LE,t.readUInt16BE=j.readUInt16BE,t.readUInt32LE=j.readUInt32LE,t.readUInt32BE=j.readUInt32BE,t.readIntLE=j.readIntLE,t.readIntBE=j.readIntBE,t.readInt8=j.readInt8,t.readInt16LE=j.readInt16LE,t.readInt16BE=j.readInt16BE,t.readInt32LE=j.readInt32LE,t.readInt32BE=j.readInt32BE,t.readFloatLE=j.readFloatLE,t.readFloatBE=j.readFloatBE,t.readDoubleLE=j.readDoubleLE,t.readDoubleBE=j.readDoubleBE,t.writeUInt8=j.writeUInt8,t.writeUIntLE=j.writeUIntLE,t.writeUIntBE=j.writeUIntBE,t.writeUInt16LE=j.writeUInt16LE,t.writeUInt16BE=j.writeUInt16BE,t.writeUInt32LE=j.writeUInt32LE,t.writeUInt32BE=j.writeUInt32BE,t.writeIntLE=j.writeIntLE,t.writeIntBE=j.writeIntBE,t.writeInt8=j.writeInt8,t.writeInt16LE=j.writeInt16LE,t.writeInt16BE=j.writeInt16BE,t.writeInt32LE=j.writeInt32LE,t.writeInt32BE=j.writeInt32BE,t.writeFloatLE=j.writeFloatLE,t.writeFloatBE=j.writeFloatBE,t.writeDoubleLE=j.writeDoubleLE,t.writeDoubleBE=j.writeDoubleBE,t.fill=j.fill,t.inspect=j.inspect,t.toArrayBuffer=j.toArrayBuffer,t};var N=/[^+\/0-9A-z\-]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s||e===c?62:e===a||e===l?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:h+26>e?e-h+26:void 0}function r(t){function r(t){h[c++]=t}var n,i,s,a,u,h;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,h=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var c=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),h}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),h="a".charCodeAt(0),f="A".charCodeAt(0),c="-".charCodeAt(0),l="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],4:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,f=-7,c=r?i-1:0,l=r?-1:1,p=t[e+c];for(c+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+c],c+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+c],c+=l,f-=8);if(0===o)o=1-h;else{if(o===u)return s?0/0:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,f=(1<<h)-1,c=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+c>=1?l/u:l*Math.pow(2,1-c),e*u>=2&&(s++,u/=2),s+c>=f?(a=0,s=f):s+c>=1?(a=(e*u-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=y,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+p]=255&s,p+=y,s/=256,h-=8);t[r+p-y]|=128*g}},{}],5:[function(t,e){var r=Array.isArray,n=Object.prototype.toString;e.exports=r||function(t){return!!t&&"[object Array]"==n.call(t)}},{}],6:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(h=r.slice(),i=h.length,u=0;i>u;u++)h[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}],7:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],8:[function(t,e){function r(t){return n(t)||i(t)}function n(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function i(t){return s[o.call(t)]}e.exports=r,r.strict=n,r.loose=i;var o=Object.prototype.toString,s={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],9:[function(t,e){function r(t,e){function n(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var n=t.apply(this,e),i=e[e.length-1];return"function"==typeof n&&n!==i&&Object.keys(i).forEach(function(t){n[t]=i[t]}),n}if(t&&e)return r(t)(e);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n}e.exports=r},{}],10:[function(t,e){function r(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}var n=t("wrappy");e.exports=n(r),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0})})},{wrappy:9}],11:[function(t,e){(function(r){var n=t("is-typedarray").strict;e.exports=function(t){var e=r.TYPED_ARRAY_SUPPORT?r._augment:function(t){return new r(t)};return t instanceof Uint8Array?e(t):t instanceof ArrayBuffer?e(new Uint8Array(t)):n(t)?e(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):new r(t)}}).call(this,t("buffer").Buffer)},{buffer:2,"is-typedarray":12}],12:[function(t,e,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],"/":[function(t,e){(function(r){function n(t,e){return this instanceof n?(i.call(this),e||(e={}),this._url=t,this._reconnect=void 0!==e.reconnect?e.reconnect:f,this.ready=!1,void this._init()):new n(t,e)}e.exports=n;var i=t("events").EventEmitter,o=t("inherits"),s=t("is-typedarray"),a=t("once"),u=t("typedarray-to-buffer"),h=t("ws"),f=5e3,c="undefined"!=typeof window?window.WebSocket:h;o(n,i),n.prototype.send=function(t){this._ws&&this._ws.readyState===c.OPEN&&this._ws.send(t instanceof ArrayBuffer||"string"==typeof t||r.isBuffer(t)||"undefined"!=typeof Blob&&t instanceof Blob?t:s.strict(t)?t.buffer:JSON.stringify(t))},n.prototype.destroy=function(t){t&&this.once("close",t);try{this._ws.close()}catch(e){this._onclose()}},n.prototype._init=function(){this._errored=!1,this._ws=new c(this._url),this._ws.binaryType="arraybuffer",this._ws.onopen=this._onopen.bind(this),this._ws.onmessage=this._onmessage.bind(this),this._ws.onclose=this._onclose.bind(this),this._ws.onerror=a(this._onerror.bind(this))},n.prototype._onopen=function(){this.ready=!0,this.emit("ready")},n.prototype._onerror=function(t){this._errored=!0,this.destroy(),this._reconnect?(this._timeout=setTimeout(this._init.bind(this),this._reconnect),this.emit("warning",t)):this.emit("error",t)},n.prototype._onmessage=function(t){var e=t.data;if(e instanceof ArrayBuffer)e=u(new Uint8Array(e));else try{e=JSON.parse(e)}catch(r){}this.emit("message",e)},n.prototype._onclose=function(){clearTimeout(this._timeout),this._ws&&(this._ws.onopen=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onclose=null),this._ws=null,this._errored||this.emit("close")}}).call(this,t("buffer").Buffer)},{buffer:2,events:6,inherits:7,"is-typedarray":8,once:10,"typedarray-to-buffer":11,ws:1}]},{},[])("/")}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.SimpleWebsocket=e()}}(function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return i(r?r:e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){},{}],2:[function(e,t,r){function n(e,t){var r=this;if(!(r instanceof n))return new n(e,t);var i,o=typeof e;if("number"===o)i=+e;else if("string"===o)i=n.byteLength(e,t);else{if("object"!==o||null===e)throw new TypeError("must start with number, buffer, array or string");"Buffer"===e.type&&C(e.data)&&(e=e.data),i=+e.length}if(i>O)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+O.toString(16)+" bytes");0>i?i=0:i>>>=0,n.TYPED_ARRAY_SUPPORT?r=n._augment(new Uint8Array(i)):(r.length=i,r._isBuffer=!0);var s;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)r._set(e);else if(R(e))if(n.isBuffer(e))for(s=0;i>s;s++)r[s]=e.readUInt8(s);else for(s=0;i>s;s++)r[s]=(e[s]%256+256)%256;else if("string"===o)r.write(e,0,t);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT)for(s=0;i>s;s++)r[s]=0;return i>0&&i<=n.poolSize&&(r.parent=D),r}function i(e,t){if(!(this instanceof i))return new i(e,t);var r=new n(e,t);return delete r.parent,r}function o(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[r+s]=a}return s}function s(e,t,r,n){var i=M(I(t,e.length-r),e,r,n);return i}function a(e,t,r,n){var i=M(k(t),e,r,n);return i}function u(e,t,r,n){return a(e,t,r,n)}function f(e,t,r,n){var i=M(U(t),e,r,n);return i}function h(e,t,r,n){var i=M(x(t,e.length-r),e,r,n);return i}function c(e,t,r){return j.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function l(e,t,r){var n="",i="";r=Math.min(e.length,r);for(var o=t;r>o;o++)e[o]<=127?(n+=T(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return n+T(i)}function d(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(127&e[i]);return n}function p(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function g(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=t;r>o;o++)i+=B(e[o]);return i}function b(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function w(e,t,r){if(e%1!==0||0>e)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function v(e,t,r,i,o,s){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>o||s>t)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range")}function m(e,t,r,n){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);o>i;i++)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function y(e,t,r,n){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);o>i;i++)e[r+i]=t>>>8*(n?i:3-i)&255}function _(e,t,r,n,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function E(e,t,r,n,i){return i||_(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),P.write(e,t,r,n,23,4),r+4}function A(e,t,r,n,i){return i||_(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),P.write(e,t,r,n,52,8),r+8}function L(e){if(e=S(e).replace(N,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function S(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function R(e){return C(e)||n.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function B(e){return 16>e?"0"+e.toString(16):e.toString(16)}function I(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;n>s;s++){if(r=e.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(56320>r){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((t-=3)>-1&&o.push(239,191,189),i=null);if(128>r){if((t-=1)<0)break;o.push(r)}else if(2048>r){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function k(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t}function x(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);s++)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function U(e){return j.toByteArray(L(e))}function M(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function T(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var j=e("base64-js"),P=e("ieee754"),C=e("is-array");r.Buffer=n,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var O=1073741823,D={};n.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(e){return!(null==e||!e._isBuffer)},n.compare=function(e,t){if(!n.isBuffer(e)||!n.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,i=t.length,o=0,s=Math.min(r,i);s>o&&e[o]===t[o];o++);return o!==s&&(r=e[o],i=t[o]),i>r?-1:r>i?1:0},n.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(e,t){if(!C(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new n(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r<e.length;r++)t+=e[r].length;var i=new n(t),o=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(i,o),o+=s.length}return i},n.byteLength=function(e,t){var r;switch(e+="",t||"utf8"){case"ascii":case"binary":case"raw":r=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*e.length;break;case"hex":r=e.length>>>1;break;case"utf8":case"utf-8":r=I(e).length;break;case"base64":r=U(e).length;break;default:r=e.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(e,t,r){var n=!1;if(t>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return g(this,t,r);case"utf8":case"utf-8":return l(this,t,r);case"ascii":return d(this,t,r);case"binary":return p(this,t,r);case"base64":return c(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}},n.prototype.equals=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===n.compare(this,e)},n.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},n.prototype.compare=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:n.compare(this,e)},n.prototype.indexOf=function(e,t){function r(e,t,r){for(var n=-1,i=0;r+i<e.length;i++)if(e[r+i]===t[-1===n?0:i-n]){if(-1===n&&(n=i),i-n+1===t.length)return r+n}else n=-1;return-1}if(t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(n.isBuffer(e))return r(this,e,t);if("number"==typeof e)return n.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},n.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},n.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},n.prototype.write=function(e,t,r,n){if(isFinite(t))isFinite(r)||(n=r,r=void 0);else{var i=n;n=t,t=r,r=i}if(t=Number(t)||0,0>r||0>t||t>this.length)throw new RangeError("attempt to write outside buffer bounds");var c=this.length-t;r?(r=Number(r),r>c&&(r=c)):r=c,n=String(n||"utf8").toLowerCase();var l;switch(n){case"hex":l=o(this,e,t,r);break;case"utf8":case"utf-8":l=s(this,e,t,r);break;case"ascii":l=a(this,e,t,r);break;case"binary":l=u(this,e,t,r);break;case"base64":l=f(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=h(this,e,t,r);break;default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(e,t));else{var o=t-e;i=new n(o,void 0);for(var s=0;o>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},n.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},n.prototype.readUInt8=function(e,t){return t||w(e,1,this.length),this[e]},n.prototype.readUInt16LE=function(e,t){return t||w(e,2,this.length),this[e]|this[e+1]<<8},n.prototype.readUInt16BE=function(e,t){return t||w(e,2,this.length),this[e]<<8|this[e+1]},n.prototype.readUInt32LE=function(e,t){return t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},n.prototype.readUInt32BE=function(e,t){return t||w(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},n.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},n.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},n.prototype.readInt8=function(e,t){return t||w(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},n.prototype.readInt16LE=function(e,t){t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(e,t){t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(e,t){return t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},n.prototype.readInt32BE=function(e,t){return t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},n.prototype.readFloatLE=function(e,t){return t||w(e,4,this.length),P.read(this,e,!0,23,4)},n.prototype.readFloatBE=function(e,t){return t||w(e,4,this.length),P.read(this,e,!1,23,4)},n.prototype.readDoubleLE=function(e,t){return t||w(e,8,this.length),P.read(this,e,!0,52,8)},n.prototype.readDoubleBE=function(e,t){return t||w(e,8,this.length),P.read(this,e,!1,52,8)},n.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||v(this,e,t,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i>>>0&255;return t+r},n.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||v(this,e,t,r,Math.pow(2,8*r),0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o>>>0&255;return t+r},n.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,1,255,0),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},n.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):m(this,e,t,!0),t+2},n.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):m(this,e,t,!1),t+2},n.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):y(this,e,t,!0),t+4},n.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):y(this,e,t,!1),t+4},n.prototype.writeIntLE=function(e,t,r,n){e=+e,t>>>=0,n||v(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=0,o=1,s=0>e?1:0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+r},n.prototype.writeIntBE=function(e,t,r,n){e=+e,t>>>=0,n||v(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=r-1,o=1,s=0>e?1:0;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+r},n.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,1,127,-128),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},n.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):m(this,e,t,!0),t+2},n.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):m(this,e,t,!1),t+2},n.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):y(this,e,t,!0),t+4},n.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||v(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):y(this,e,t,!1),t+4},n.prototype.writeFloatLE=function(e,t,r){return E(this,e,t,!0,r)},n.prototype.writeFloatBE=function(e,t,r){return E(this,e,t,!1,r)},n.prototype.writeDoubleLE=function(e,t,r){return A(this,e,t,!0,r)},n.prototype.writeDoubleBE=function(e,t,r){return A(this,e,t,!1,r)},n.prototype.copy=function(e,t,r,i){if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var o=i-r;if(1e3>o||!n.TYPED_ARRAY_SUPPORT)for(var s=0;o>s;s++)e[s+t]=this[s+r];else e._set(this.subarray(r,r+o),t);return o},n.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof e)for(n=t;r>n;n++)this[n]=e;else{var i=I(e.toString()),o=i.length;for(n=t;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var Y=n.prototype;n._augment=function(e){return e.constructor=n,e._isBuffer=!0,e._set=e.set,e.get=Y.get,e.set=Y.set,e.write=Y.write,e.toString=Y.toString,e.toLocaleString=Y.toString,e.toJSON=Y.toJSON,e.equals=Y.equals,e.compare=Y.compare,e.indexOf=Y.indexOf,e.copy=Y.copy,e.slice=Y.slice,e.readUIntLE=Y.readUIntLE,e.readUIntBE=Y.readUIntBE,e.readUInt8=Y.readUInt8,e.readUInt16LE=Y.readUInt16LE,e.readUInt16BE=Y.readUInt16BE,e.readUInt32LE=Y.readUInt32LE,e.readUInt32BE=Y.readUInt32BE,e.readIntLE=Y.readIntLE,e.readIntBE=Y.readIntBE,e.readInt8=Y.readInt8,e.readInt16LE=Y.readInt16LE,e.readInt16BE=Y.readInt16BE,e.readInt32LE=Y.readInt32LE,e.readInt32BE=Y.readInt32BE,e.readFloatLE=Y.readFloatLE,e.readFloatBE=Y.readFloatBE,e.readDoubleLE=Y.readDoubleLE,e.readDoubleBE=Y.readDoubleBE,e.writeUInt8=Y.writeUInt8,e.writeUIntLE=Y.writeUIntLE,e.writeUIntBE=Y.writeUIntBE,e.writeUInt16LE=Y.writeUInt16LE,e.writeUInt16BE=Y.writeUInt16BE,e.writeUInt32LE=Y.writeUInt32LE,e.writeUInt32BE=Y.writeUInt32BE,e.writeIntLE=Y.writeIntLE,e.writeIntBE=Y.writeIntBE,e.writeInt8=Y.writeInt8,e.writeInt16LE=Y.writeInt16LE,e.writeInt16BE=Y.writeInt16BE,e.writeInt32LE=Y.writeInt32LE,e.writeInt32BE=Y.writeInt32BE,e.writeFloatLE=Y.writeFloatLE,e.writeFloatBE=Y.writeFloatBE,e.writeDoubleLE=Y.writeDoubleLE,e.writeDoubleBE=Y.writeDoubleBE,e.fill=Y.fill,e.inspect=Y.inspect,e.toArrayBuffer=Y.toArrayBuffer,e};var N=/[^+\/0-9A-z\-]/g},{"base64-js":3,ieee754:4,"is-array":5}],3:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===c?62:t===a||t===l?63:u>t?-1:u+10>t?t-u+26+26:h+26>t?t-h:f+26>t?t-f+26:void 0}function r(e){function r(e){f[c++]=e}var n,i,s,a,u,f;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var h=e.length;u="="===e.charAt(h-2)?2:"="===e.charAt(h-1)?1:0,f=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var c=0;for(n=0,i=0;s>n;n+=4,i+=3)a=t(e.charAt(n))<<18|t(e.charAt(n+1))<<12|t(e.charAt(n+2))<<6|t(e.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=t(e.charAt(n))<<2|t(e.charAt(n+1))>>4,r(255&a)):1===u&&(a=t(e.charAt(n))<<10|t(e.charAt(n+1))<<4|t(e.charAt(n+2))>>2,r(a>>8&255),r(255&a)),f}function i(e){function t(e){return n.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=r(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),f="a".charCodeAt(0),h="A".charCodeAt(0),c="-".charCodeAt(0),l="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],4:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,f=u>>1,h=-7,c=r?i-1:0,l=r?-1:1,d=e[t+c];for(c+=l,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+c],c+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+c],c+=l,h-=8);if(0===o)o=1-f;else{if(o===u)return s?0/0:(d?-1:1)*(1/0);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,u,f=8*o-i-1,h=(1<<f)-1,c=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+c>=1?l/u:l*Math.pow(2,1-c),t*u>=2&&(s++,u/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(t*u-1)*Math.pow(2,i),s+=c):(a=t*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*g}},{}],5:[function(e,t,r){var n=Array.isArray,i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],6:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"number"==typeof e}function s(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,o,u,f;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];r.apply(this,o)}else if(s(r)){for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];for(f=r.slice(),n=f.length,u=0;n>u;u++)f[u].apply(this,o)}return!0},n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var n=!1;return r.listener=t,this.on(e,r),this},n.prototype.removeListener=function(e,t){var r,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],o=r.length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(r)){for(a=o;a-->0;)if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],i(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var r;return r=e._events&&e._events[t]?i(e._events[t])?1:e._events[t].length:0}},{}],7:[function(e,t,r){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],8:[function(e,t,r){function n(){if(!a){a=!0;for(var e,t=s.length;t;){e=s,s=[];for(var r=-1;++r<t;)e[r]();t=s.length}a=!1}}function i(){}var o=t.exports={},s=[],a=!1;o.nextTick=function(e){s.push(e),a||setTimeout(n,0)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=i,o.addListener=i,o.once=i,o.off=i,o.removeListener=i,o.removeAllListeners=i,o.emit=i,o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],9:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":10}],10:[function(e,t,r){(function(r){function n(e){return this instanceof n?(u.call(this,e),f.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",i)):new n(e)}function i(){this.allowHalfOpen||this._writableState.ended||r.nextTick(this.end.bind(this))}function o(e,t){for(var r=0,n=e.length;n>r;r++)t(e[r],r)}t.exports=n;var s=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t},a=e("core-util-is");a.inherits=e("inherits");var u=e("./_stream_readable"),f=e("./_stream_writable");a.inherits(n,u),o(s(f.prototype),function(e){n.prototype[e]||(n.prototype[e]=f.prototype[e])})}).call(this,e("_process"))},{"./_stream_readable":12,"./_stream_writable":14,_process:8,"core-util-is":15,inherits:25}],11:[function(e,t,r){function n(e){return this instanceof n?void i.call(this,e):new n(e)}t.exports=n;var i=e("./_stream_transform"),o=e("core-util-is");o.inherits=e("inherits"),o.inherits(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":13,"core-util-is":15,inherits:25}],12:[function(e,t,r){(function(r){function n(t,r){var n=e("./_stream_duplex");t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,r instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(I||(I=e("string_decoder/").StringDecoder),this.decoder=new I(t.encoding),this.encoding=t.encoding)}function i(t){e("./_stream_duplex");return this instanceof i?(this._readableState=new n(t,this),this.readable=!0,void R.call(this)):new i(t)}function o(e,t,r,n,i){var o=f(t,r);if(o)e.emit("error",o);else if(B.isNullOrUndefined(r))t.reading=!1,t.ended||h(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||n||(r=t.decoder.write(r)),i||(t.reading=!1),t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&c(e)),d(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){if(e>=x)e=x;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||B.isNull(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function f(e,t){var r=null;return B.isBuffer(t)||B.isString(t)||B.isNullOrUndefined(t)||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function h(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,c(e)}function c(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(k("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?r.nextTick(function(){l(e)}):l(e))}function l(e){k("emit readable"),e.emit("readable"),v(e)}function d(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(function(){p(e,t)}))}function p(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(k("maybeReadMore read 0"),e.read(0),r!==t.length);)r=t.length;t.readingMore=!1}function g(e){return function(){var t=e._readableState;k("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&S.listenerCount(e,"data")&&(t.flowing=!0,v(e))}}function b(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(function(){w(e,t)}))}function w(e,t){t.resumeScheduled=!1,e.emit("resume"),v(e),t.flowing&&!t.reading&&e.read(0)}function v(e){var t=e._readableState;if(k("flow",t.flowing),t.flowing)do var r=e.read();while(null!==r&&t.flowing)}function m(e,t){var r,n=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===n.length)return null;if(0===i)r=null;else if(s)r=n.shift();else if(!e||e>=i)r=o?n.join(""):L.concat(n,i),n.length=0;else if(e<n[0].length){var a=n[0];r=a.slice(0,e),n[0]=a.slice(e)}else if(e===n[0].length)r=n.shift();else{r=o?"":new L(e);for(var u=0,f=0,h=n.length;h>f&&e>u;f++){var a=n[0],c=Math.min(e-u,a.length);o?r+=a.slice(0,c):a.copy(r,u,0,c),c<a.length?n[0]=a.slice(c):n.shift(),u+=c}}return r}function y(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,r.nextTick(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function _(e,t){for(var r=0,n=e.length;n>r;r++)t(e[r],r)}function E(e,t){for(var r=0,n=e.length;n>r;r++)if(e[r]===t)return r;return-1}t.exports=i;var A=e("isarray"),L=e("buffer").Buffer;i.ReadableState=n;var S=e("events").EventEmitter;S.listenerCount||(S.listenerCount=function(e,t){return e.listeners(t).length});var R=e("stream"),B=e("core-util-is");B.inherits=e("inherits");var I,k=e("util");k=k&&k.debuglog?k.debuglog("stream"):function(){},B.inherits(i,R),i.prototype.push=function(e,t){var r=this._readableState;return B.isString(e)&&!r.objectMode&&(t=t||r.defaultEncoding,t!==r.encoding&&(e=new L(e,t),t="")),o(this,r,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(t){return I||(I=e("string_decoder/").StringDecoder),this._readableState.decoder=new I(t),this._readableState.encoding=t,this};var x=8388608;i.prototype.read=function(e){k("read",e);var t=this._readableState,r=e;if((!B.isNumber(e)||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return k("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?y(this):c(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&y(this),null;var n=t.needReadable;k("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&(n=!0,k("length less than watermark",n)),(t.ended||t.reading)&&(n=!1,k("reading or ended",n)),n&&(k("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),n&&!t.reading&&(e=u(r,t));var i;return i=e>0?m(e,t):null,B.isNull(i)&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),r!==e&&t.ended&&0===t.length&&y(this),B.isNull(i)||this.emit("data",i),i},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function n(e){k("onunpipe"),e===c&&o()}function i(){k("onend"),e.end()}function o(){k("cleanup"),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("drain",b),e.removeListener("error",a),e.removeListener("unpipe",n),c.removeListener("end",i),c.removeListener("end",o),c.removeListener("data",s),!l.awaitDrain||e._writableState&&!e._writableState.needDrain||b()}function s(t){k("ondata");var r=e.write(t);!1===r&&(k("false write response, pause",c._readableState.awaitDrain),c._readableState.awaitDrain++,c.pause())}function a(t){k("onerror",t),h(),e.removeListener("error",a),0===S.listenerCount(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",f),h()}function f(){k("onfinish"),e.removeListener("close",u),h()}function h(){k("unpipe"), | ||
c.unpipe(e)}var c=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1,k("pipe count=%d opts=%j",l.pipesCount,t);var d=(!t||t.end!==!1)&&e!==r.stdout&&e!==r.stderr,p=d?i:o;l.endEmitted?r.nextTick(p):c.once("end",p),e.on("unpipe",n);var b=g(c);return e.on("drain",b),c.on("data",s),e._events&&e._events.error?A(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",u),e.once("finish",f),e.emit("pipe",c),l.flowing||(k("pipe resume"),c.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;n>i;i++)r[i].emit("unpipe",this);return this}var i=E(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=R.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&this.readable){var i=this._readableState;if(!i.readableListening)if(i.readableListening=!0,i.emittedReadable=!1,i.needReadable=!0,i.reading)i.length&&c(this,i);else{var o=this;r.nextTick(function(){k("readable nexttick read 0"),o.read(0)})}}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var e=this._readableState;return e.flowing||(k("resume"),e.flowing=!0,e.reading||(k("resume read 0"),this.read(0)),b(this,e)),this},i.prototype.pause=function(){return k("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(k("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(e){var t=this._readableState,r=!1,n=this;e.on("end",function(){if(k("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&n.push(e)}n.push(null)}),e.on("data",function(i){if(k("wrapped data"),t.decoder&&(i=t.decoder.write(i)),i&&(t.objectMode||i.length)){var o=n.push(i);o||(r=!0,e.pause())}});for(var i in e)B.isFunction(e[i])&&B.isUndefined(this[i])&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return _(o,function(t){e.on(t,n.emit.bind(n,t))}),n._read=function(t){k("wrapped _read",t),r&&(r=!1,e.resume())},n},i._fromList=m}).call(this,e("_process"))},{"./_stream_duplex":10,_process:8,buffer:2,"core-util-is":15,events:6,inherits:25,isarray:7,stream:20,"string_decoder/":21,util:1}],13:[function(e,t,r){function n(e,t){this.afterTransform=function(e,r){return i(t,e,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function i(e,t,r){var n=e._transformState;n.transforming=!1;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,u.isNullOrUndefined(r)||e.push(r),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function o(e){if(!(this instanceof o))return new o(e);a.call(this,e),this._transformState=new n(e,this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("prefinish",function(){u.isFunction(this._flush)?this._flush(function(e){s(t,e)}):s(t)})}function s(e,t){if(t)return e.emit("error",t);var r=e._writableState,n=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=o;var a=e("./_stream_duplex"),u=e("core-util-is");u.inherits=e("inherits"),u.inherits(o,a),o.prototype.push=function(e,t){return this._transformState.needTransform=!1,a.prototype.push.call(this,e,t)},o.prototype._transform=function(e,t,r){throw new Error("not implemented")},o.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},o.prototype._read=function(e){var t=this._transformState;u.isNull(t.writechunk)||!t.writecb||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))}},{"./_stream_duplex":10,"core-util-is":15,inherits:25}],14:[function(e,t,r){(function(r){function n(e,t,r){this.chunk=e,this.encoding=t,this.callback=r}function i(t,r){var n=e("./_stream_duplex");t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.objectMode=!!t.objectMode,r instanceof n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var s=t.decodeStrings===!1;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(r,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function o(t){var r=e("./_stream_duplex");return this instanceof o||this instanceof r?(this._writableState=new i(t,this),this.writable=!0,void A.call(this)):new o(t)}function s(e,t,n){var i=new Error("write after end");e.emit("error",i),r.nextTick(function(){n(i)})}function a(e,t,n,i){var o=!0;if(!(E.isBuffer(n)||E.isString(n)||E.isNullOrUndefined(n)||t.objectMode)){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),r.nextTick(function(){i(s)}),o=!1}return o}function u(e,t,r){return!e.objectMode&&e.decodeStrings!==!1&&E.isString(t)&&(t=new _(t,r)),t}function f(e,t,r,i,o){r=u(t,r,i),E.isBuffer(r)&&(i="buffer");var s=t.objectMode?1:r.length;t.length+=s;var a=t.length<t.highWaterMark;return a||(t.needDrain=!0),t.writing||t.corked?t.buffer.push(new n(r,i,o)):h(e,t,!1,s,r,i,o),a}function h(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function c(e,t,n,i,o){n?r.nextTick(function(){t.pendingcb--,o(i)}):(t.pendingcb--,o(i)),e._writableState.errorEmitted=!0,e.emit("error",i)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function d(e,t){var n=e._writableState,i=n.sync,o=n.writecb;if(l(n),t)c(e,n,i,t,o);else{var s=w(e,n);s||n.corked||n.bufferProcessing||!n.buffer.length||b(e,n),i?r.nextTick(function(){p(e,n,s,o)}):p(e,n,s,o)}}function p(e,t,r,n){r||g(e,t),t.pendingcb--,n(),m(e,t)}function g(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function b(e,t){if(t.bufferProcessing=!0,e._writev&&t.buffer.length>1){for(var r=[],n=0;n<t.buffer.length;n++)r.push(t.buffer[n].callback);t.pendingcb++,h(e,t,!0,t.length,t.buffer,"",function(e){for(var n=0;n<r.length;n++)t.pendingcb--,r[n](e)}),t.buffer=[]}else{for(var n=0;n<t.buffer.length;n++){var i=t.buffer[n],o=i.chunk,s=i.encoding,a=i.callback,u=t.objectMode?1:o.length;if(h(e,t,!1,u,o,s,a),t.writing){n++;break}}n<t.buffer.length?t.buffer=t.buffer.slice(n):t.buffer.length=0}t.bufferProcessing=!1}function w(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function v(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function m(e,t){var r=w(e,t);return r&&(0===t.pendingcb?(v(e,t),t.finished=!0,e.emit("finish")):v(e,t)),r}function y(e,t,n){t.ending=!0,m(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n)),t.ended=!0}t.exports=o;var _=e("buffer").Buffer;o.WritableState=i;var E=e("core-util-is");E.inherits=e("inherits");var A=e("stream");E.inherits(o,A),o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(e,t,r){var n=this._writableState,i=!1;return E.isFunction(t)&&(r=t,t=null),E.isBuffer(e)?t="buffer":t||(t=n.defaultEncoding),E.isFunction(r)||(r=function(){}),n.ended?s(this,n,r):a(this,n,e,r)&&(n.pendingcb++,i=f(this,n,e,t,r)),i},o.prototype.cork=function(){var e=this._writableState;e.corked++},o.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.buffer.length||b(this,e))},o.prototype._write=function(e,t,r){r(new Error("not implemented"))},o.prototype._writev=null,o.prototype.end=function(e,t,r){var n=this._writableState;E.isFunction(e)?(r=e,e=null,t=null):E.isFunction(t)&&(r=t,t=null),E.isNullOrUndefined(e)||this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||y(this,n,r)}}).call(this,e("_process"))},{"./_stream_duplex":10,_process:8,buffer:2,"core-util-is":15,inherits:25,stream:20}],15:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}function n(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function f(e){return void 0===e}function h(e){return c(e)&&"[object RegExp]"===w(e)}function c(e){return"object"==typeof e&&null!==e}function l(e){return c(e)&&"[object Date]"===w(e)}function d(e){return c(e)&&("[object Error]"===w(e)||e instanceof Error)}function p(e){return"function"==typeof e}function g(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function b(t){return e.isBuffer(t)}function w(e){return Object.prototype.toString.call(e)}r.isArray=t,r.isBoolean=n,r.isNull=i,r.isNullOrUndefined=o,r.isNumber=s,r.isString=a,r.isSymbol=u,r.isUndefined=f,r.isRegExp=h,r.isObject=c,r.isDate=l,r.isError=d,r.isFunction=p,r.isPrimitive=g,r.isBuffer=b}).call(this,e("buffer").Buffer)},{buffer:2}],16:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":11}],17:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js"),r.Stream=e("stream"),r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":10,"./lib/_stream_passthrough.js":11,"./lib/_stream_readable.js":12,"./lib/_stream_transform.js":13,"./lib/_stream_writable.js":14,stream:20}],18:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":13}],19:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":14}],20:[function(e,t,r){function n(){i.call(this)}t.exports=n;var i=e("events").EventEmitter,o=e("inherits");o(n,i),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){function r(t){e.writable&&!1===e.write(t)&&f.pause&&f.pause()}function n(){f.readable&&f.resume&&f.resume()}function o(){h||(h=!0,e.end())}function s(){h||(h=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(u(),0===i.listenerCount(this,"error"))throw e}function u(){f.removeListener("data",r),e.removeListener("drain",n),f.removeListener("end",o),f.removeListener("close",s),f.removeListener("error",a),e.removeListener("error",a),f.removeListener("end",u),f.removeListener("close",u),e.removeListener("close",u)}var f=this;f.on("data",r),e.on("drain",n),e._isStdio||t&&t.end===!1||(f.on("end",o),f.on("close",s));var h=!1;return f.on("error",a),e.on("error",a),f.on("end",u),f.on("close",u),e.on("close",u),e.emit("pipe",f),e}},{events:6,inherits:25,"readable-stream/duplex.js":9,"readable-stream/passthrough.js":16,"readable-stream/readable.js":17,"readable-stream/transform.js":18,"readable-stream/writable.js":19}],21:[function(e,t,r){function n(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}},f=r.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),n(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};f.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";e=e.slice(r,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(!(n>=55296&&56319>=n)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),t+=e.toString(this.encoding,0,i);var i=t.length-1,n=t.charCodeAt(i);if(n>=55296&&56319>=n){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},f.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(2>=t&&r>>4==14){this.charLength=3;break}if(3>=t&&r>>3==30){this.charLength=4;break}}this.charReceived=t},f.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t}},{buffer:2}],22:[function(e,t,r){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function i(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,o=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,n),e}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?f.removeItem("debug"):f.debug=e}catch(t){}}function a(){var e;try{e=f.debug}catch(t){}return e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e("./debug"),r.log=o,r.formatArgs=i,r.save=s,r.load=a,r.useColors=n;var f;f="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){return JSON.stringify(e)},r.enable(a())},{"./debug":23}],23:[function(e,t,r){function n(){return r.colors[h++%r.colors.length]}function i(e){function t(){}function i(){var e=i,t=+new Date,o=t-(f||t);e.diff=o,e.prev=f,e.curr=t,f=t,null==e.useColors&&(e.useColors=r.useColors()),null==e.color&&e.useColors&&(e.color=n());var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,n){if("%%"===t)return t;a++;var i=r.formatters[n];if("function"==typeof i){var o=s[a];t=i.call(e,o),s.splice(a,1),a--}return t}),"function"==typeof r.formatArgs&&(s=r.formatArgs.apply(e,s));var u=i.log||r.log||console.log.bind(console);u.apply(e,s)}t.enabled=!1,i.enabled=!0;var o=r.enabled(e)?i:t;return o.namespace=e,o}function o(e){r.save(e);for(var t=(e||"").split(/[\s,]+/),n=t.length,i=0;n>i;i++)t[i]&&(e=t[i].replace(/\*/g,".*?"),"-"===e[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){r.enable("")}function a(e){var t,n;for(t=0,n=r.skips.length;n>t;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;n>t;t++)if(r.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}r=t.exports=i,r.coerce=u,r.disable=s,r.enable=o,r.enabled=a,r.humanize=e("ms"),r.names=[],r.skips=[],r.formatters={};var f,h=0},{ms:24}],24:[function(e,t,r){function n(e){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*c;case"days":case"day":case"d":return r*h;case"hours":case"hour":case"hrs":case"hr":case"h":return r*f;case"minutes":case"minute":case"mins":case"min":case"m":return r*u;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}function i(e){return e>=h?Math.round(e/h)+"d":e>=f?Math.round(e/f)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function o(e){return s(e,h,"day")||s(e,f,"hour")||s(e,u,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,r){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var a=1e3,u=60*a,f=60*u,h=24*f,c=365.25*h;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?o(e):i(e)}},{}],25:[function(e,t,r){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],26:[function(e,t,r){function n(e){return i(e)||o(e)}function i(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function o(e){return a[s.call(e)]}t.exports=n,n.strict=i,n.loose=o;var s=Object.prototype.toString,a={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],27:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};return e instanceof Uint8Array?t(e):e instanceof ArrayBuffer?t(new Uint8Array(e)):n(e)?t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):new r(e)}}).call(this,e("buffer").Buffer)},{buffer:2,"is-typedarray":26}],"/":[function(e,t,r){(function(r){function n(e,t){var r=this;return r instanceof n?(t||(t={}),o("new websocket %s %o",e,t),t.allowHalfOpen=!1,u.Duplex.call(r,t),r.url=e,r.connected=!1,r.destroyed=!1,r._buffer=[],r._ws=new c(r.url),r._ws.binaryType="arraybuffer",r._ws.onopen=r._onOpen.bind(r),r._ws.onmessage=r._onMessage.bind(r),r._ws.onclose=r._onClose.bind(r),r._ws.onerror=r._onError.bind(r),void r.on("finish",function(){r.connected?r._destroy():r.once("connect",function(){setTimeout(function(){r._destroy()},100)})})):new n(e,t)}function i(){}t.exports=n;var o=e("debug")("simple-websocket"),s=e("inherits"),a=e("is-typedarray"),u=e("stream"),f=e("typedarray-to-buffer"),h=e("ws"),c="undefined"!=typeof window?window.WebSocket:h;s(n,u.Duplex),n.prototype.send=function(e,t){var r=this;t||(t=i),r._write(e,void 0,t)},n.prototype.destroy=function(e){var t=this;t._destroy(null,e)},n.prototype._destroy=function(e,t){var r=this;if(!r.destroyed){if(t&&r.once("close",t),o("destroy (error: %s)",e&&e.message),r.connected=!1,r.destroyed=!0,r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null,r._ws.onmessage=null,r._ws.onclose=null,r._ws.onerror=null}r._ws=null,this.readable=this.writable=!1,r._readableState.ended||r.push(null),r._writableState.finished||r.end(),e&&r.emit("error",e),r.emit("close")}},n.prototype._read=function(){},n.prototype._write=function(e,t,n){var i=this;if(i.destroyed)return n(new Error("cannot write after socket is destroyed"));var s=e.length||e.byteLength||e.size;return i.connected?(o("_write: length %d",s),i._ws.send(a.strict(e)||e instanceof ArrayBuffer||r.isBuffer(e)||"string"==typeof e||"undefined"!=typeof Blob&&e instanceof Blob?e:JSON.stringify(e)),void n(null)):(o("_write before ready: length %d",s),i._buffer.push(e),void n(null))},n.prototype._onMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;if(o("on message: length %d",n.byteLength||n.length),n instanceof ArrayBuffer)n=f(new Uint8Array(n)),t.push(n);else if(r.isBuffer(n))t.push(n);else{try{n=JSON.parse(n)}catch(i){}t.emit("data",n)}}},n.prototype._onOpen=function(){var e=this;e.connected||e.destroyed||(e.connected=!0,e._buffer.forEach(function(t){e.send(t)}),e._buffer=[],o("connect"),e.emit("connect"))},n.prototype._onClose=function(){var e=this;e.destroyed||(o("on close"),e._destroy())},n.prototype._onError=function(e){var t=this;t.destroyed||(o("error %s",e.message||e),t._destroy(e))}}).call(this,e("buffer").Buffer)},{buffer:2,debug:22,inherits:25,"is-typedarray":26,stream:20,"typedarray-to-buffer":27,ws:1}]},{},[])("/")}); |
@@ -10,6 +10,6 @@ var Socket = require('../') | ||
var socket = new Socket(SOCKET_SERVER) | ||
socket.on('ready', function () { | ||
t.pass('ready emitted') | ||
socket.on('connect', function () { | ||
t.pass('connect emitted') | ||
socket.send('sup!') | ||
socket.on('message', function (data) { | ||
socket.on('data', function (data) { | ||
t.equal(data, 'sup!') | ||
@@ -28,8 +28,8 @@ | ||
var socket = new Socket(SOCKET_SERVER) | ||
socket.on('ready', function () { | ||
t.pass('ready emitted') | ||
socket.on('connect', function () { | ||
t.pass('connect emitted') | ||
socket.send(new Uint8Array([1, 2, 3])) | ||
socket.on('message', function (data) { | ||
socket.on('data', function (data) { | ||
t.ok(Buffer.isBuffer(data), 'data is Buffer') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct data') | ||
@@ -47,8 +47,8 @@ socket.destroy(function () { | ||
var socket = new Socket(SOCKET_SERVER) | ||
socket.on('ready', function () { | ||
t.pass('ready emitted') | ||
socket.on('connect', function () { | ||
t.pass('connect emitted') | ||
socket.send(new Buffer([1, 2, 3])) | ||
socket.on('message', function (data) { | ||
socket.on('data', function (data) { | ||
t.ok(Buffer.isBuffer(data), 'data is Buffer') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct data') | ||
@@ -66,8 +66,8 @@ socket.destroy(function () { | ||
var socket = new Socket(SOCKET_SERVER) | ||
socket.on('ready', function () { | ||
t.pass('ready emitted') | ||
socket.on('connect', function () { | ||
t.pass('connect emitted') | ||
socket.send(new Uint8Array([1, 2, 3]).buffer) | ||
socket.on('message', function (data) { | ||
socket.on('data', function (data) { | ||
t.ok(Buffer.isBuffer(data), 'data is Buffer') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct message') | ||
t.deepEqual(data, new Buffer([1, 2, 3]), 'got correct data') | ||
@@ -74,0 +74,0 @@ socket.destroy(function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
67834
9
375
+ Addeddebug@^2.1.3
+ Addeddebug@2.6.9(transitive)
+ Addedms@2.0.0(transitive)
- Removedonce@^1.3.0
- Removedonce@1.4.0(transitive)
- Removedwrappy@1.0.2(transitive)