()
| 2 | correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.QOS=[0,1,2].map(t=>e.from([t])),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:3}],8:[function(e,t,r){(function(r){(function(){function n(e,t){const r=new s;return i(e,r,t),r.concat()}const i=e("./writeToStream"),o=e("events");class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),n=this._array;let i,o=0;for(i=0;i<n.length&&void 0!==n[i];i++)"string"!=typeof n[i]?t[i]=n[i].length:t[i]=r.byteLength(n[i]),e+=t[i];const s=r.allocUnsafe(e);for(i=0;i<n.length&&void 0!==n[i];i++)"string"!=typeof n[i]?(n[i].copy(s,o),o+=t[i]):(s.write(n[i],o),o+=t[i]);return s}}t.exports=n}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":38,buffer:3,events:4}],9:[function(e,t,r){window.parser=e("./parser").parser,window.generate=e("./generate"),window.writeToStream=e("./writeToStream")},{"./generate":8,"./parser":37,"./writeToStream":38}],10:[function(e,t,r){"use strict";function n(e){if(!(this instanceof n))return new n(e);n._init.call(this,e)}const{Buffer:i}=e("buffer"),o=Symbol.for("BufferList");n._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},n.prototype._new=function(e){return new n(e)},n.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return[r,e-t];t=n}},n.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},n.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},n.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},n.prototype.copy=function(e,t,r,n){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof n||n>this.length)&&(n=this.length),r>=this.length)return e||i.alloc(0);if(n<=0)return e||i.alloc(0);const o=!!e,s=this._offset(r),a=n-r;let u=a,l=o&&t||0,f=s[1];if(0===r&&n===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:i.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(u<=this._bufs[s[0]].length-f)return o?this._bufs[s[0]].copy(e,t,f,f+u):this._bufs[s[0]].slice(f,f+u);o||(e=i.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-f;if(!(u>r)){this._bufs[t].copy(e,l,f,f+u),l+=r;break}this._bufs[t].copy(e,l,f),l+=r,u-=r,f&&(f=0)}return e.length>l?e.slice(0,l):e},n.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},n.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},n.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},n.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},n.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(i.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(i.from(e));return this},n.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},n.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=i.from([e]):"string"==typeof e?e=i.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=i.from(e.buffer,e.byteOffset,e.byteLength):i.isBuffer(e)||(e=i.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const n=this._offset(t);let o=n[0],s=n[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;s<t.length;){const r=t.length-s;if(r>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}}s=0}return-1},n.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)(function(t){null===e[t]?n.prototype[t]=function(e,r){return this.slice(e,e+r)[t](0,r)}:n.prototype[t]=function(r){return this.slice(r,r+e[t])[t](0)}})(t)}(),n.prototype._isBufferList=function(e){return e instanceof n||n.isBufferList(e)},n.isBufferList=function(e){return null!=e&&e[o]},t.exports=n},{buffer:3}],11:[function(e,t,r){"use strict";function n(e){if(!(this instanceof n))return new n(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",function(e){e.on("error",t)}),this.on("unpipe",function(e){e.removeListener("error",t)}),e=null}s._init.call(this,e),i.call(this)}const i=e("readable-stream").Duplex,o=e("inherits"),s=e("./BufferList");o(n,i),Object.assign(n.prototype,s.prototype),n.prototype._new=function(e){return new n(e)},n.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},n.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},n.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},n.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},n.prototype._isBufferList=function(e){return e instanceof n||e instanceof s||n.isBufferList(e)},n.isBufferList=s.isBufferList,t.exports=n,t.exports.BufferListStream=n,t.exports.BufferList=s},{"./BufferList":10,inherits:14,"readable-stream":31}],12:[function(e,t,r){(function(n){(function(){function i(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,r)}function s(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=r.storage.getItem("debug")}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}function u(){try{return localStorage}catch(e){}}r.formatArgs=o,r.save=s,r.load=a,r.useColors=i,r.storage=u(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":13,_process:6}],13:[function(e,t,r){function n(t){function r(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){function t(...e){if(!t.enabled)return;const i=t,o=Number(new Date),s=o-(r||o);i.diff=s,i.prev=r,i.curr=o,r=o,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return"%";a++;const o=n.formatters[r];if("function"==typeof o){const r=e[a];t=o.call(i,r),e.splice(a,1),a--}return t}),n.formatArgs.call(i,e);const u=i.log||n.log;u.apply(i,e)}let r,o=null;return t.namespace=e,t.useColors=n.useColors(),t.color=n.selectColor(e),t.extend=i,t.destroy=n.destroy,Object.defineProperty(t,"enabled",{enumerable:!0,configurable:!1,get:()=>null===o?n.enabled(e):o,set:e=>{o=e}}),"function"==typeof n.init&&n.init(t),t}function i(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function o(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t<i;t++)r[t]&&(e=r[t].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...n.names.map(u),...n.skips.map(u).map(e=>"-"+e)].join(",");return n.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.debug=n,n.default=n,n.coerce=l,n.disable=s,n.enable=o,n.enabled=a,n.humanize=e("ms"),n.destroy=f,Object.keys(t).forEach(e=>{n[e]=t[e]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=r,n.enable(n.load()),n}t.exports=n},{ms:15}],14:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],15:[function(e,t,r){function n(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|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*h;case"weeks":case"week":case"w":return r*c;case"days":case"day":case"d":return r*f;case"hours":case"hour":case"hrs":case"hr":case"h":return r*l;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;default:return}}}}function i(e){var t=Math.abs(e);return t>=f?Math.round(e/f)+"d":t>=l?Math.round(e/l)+"h":t>=u?Math.round(e/u)+"m":t>=a?Math.round(e/a)+"s":e+"ms"}function o(e){var t=Math.abs(e);return t>=f?s(e,t,f,"day"):t>=l?s(e,t,l,"hour"):t>=u?s(e,t,u,"minute"):t>=a?s(e,t,a,"second"):e+" ms"}function s(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var a=1e3,u=60*a,l=60*u,f=24*l,c=7*f,h=365.25*f;t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return n(e);if("number"===r&&isFinite(e))return t.long?o(e):i(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],16:[function(e,t,r){(function(e){(function(){"use strict";function r(t,r,n,i){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick(function(){t.apply(null,o)})}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:r}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:6}],17:[function(e,t,r){"use strict";function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function i(e,t,r){function i(e,r,n){return"string"==typeof t?t:t(e,r,n)}r||(r=Error);var o=function(e){function t(t,r,n){return e.call(this,i(t,r,n))||this}return n(t,e),t}(r);o.prototype.name=r.name,o.prototype.code=e,l[e]=o}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(e){return String(e)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function s(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function a(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function u(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}var l={};i("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(e,t,r){var n,i;if("string"==typeof t&&s(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be",a(e," argument"))i="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var l=u(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(l," ").concat(n," ").concat(o(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=l},{}],18:[function(e,t,r){(function(r){(function(){"use strict";function n(e){if(!(this instanceof n))return new n(e);a.call(this,e),u.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",i)))}function i(){this._writableState.ended||r.nextTick(o,this)}function o(e){e.end()}var s=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=n;var a=e("./_stream_readable"),u=e("./_stream_writable");e("inherits")(n,a);for(var l=s(u.prototype),f=0;f<l.length;f++){var c=l[f];n.prototype[c]||(n.prototype[c]=u.prototype[c])}Object.defineProperty(n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(n.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(n.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(n.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":20,"./_stream_writable":22,_process:6,inherits:14}],19:[function(e,t,r){"use strict";function n(e){if(!(this instanceof n))return new n(e);i.call(this,e)}t.exports=n;var i=e("./_stream_transform");e("inherits")(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":21,inherits:14}],20:[function(e,t,r){(function(r,n){(function(){"use strict";function i(e){return M.from(e)}function o(e){return M.isBuffer(e)||e instanceof N}function s(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}function a(t,r,n){T=T||e("./_stream_duplex"),t=t||{},"boolean"!=typeof n&&(n=r instanceof T),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=q(this,t,"readableHighWaterMark",n),this.buffer=new F,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.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(x||(x=e("string_decoder/").StringDecoder),this.decoder=new x(t.encoding),this.encoding=t.encoding)}function u(t){if(T=T||e("./_stream_duplex"),!(this instanceof u))return new u(t);var r=this instanceof T;this._readableState=new a(t,this,r),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),L.call(this)}function l(e,t,r,n,o){O("readableAddChunk",t);var s,a=e._readableState;if(null===t)a.reading=!1,d(e,a);else if(o||(s=c(a,t)),s)Y(e,s);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===M.prototype||(t=i(t)),n)a.endEmitted?Y(e,new Q):f(e,a,t,!0);else if(a.ended)Y(e,new W);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?f(e,a,t,!1):y(e,a)):f(e,a,t,!1)}else n||(a.reading=!1,y(e,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function f(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&g(e)),y(e,t)}function c(e,t){var r;return o(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new V("chunk",["string","Buffer","Uint8Array"],t)),r}function h(e){return e>=G?e=G:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function p(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function d(e,t){if(O("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?g(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,b(e)))}}function g(e){var t=e._readableState;O("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(O("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(b,e))}function b(e){var t=e._readableState;O("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,C(e)}function y(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(_,e,t))}function _(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(O("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function m(e){return function(){var t=e._readableState;O("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&B(e,"data")&&(t.flowing=!0,C(e))}}function w(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function v(e){O("readable nexttick read 0"),e.read(0)}function S(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(E,e,t))}function E(e,t){O("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),C(e),t.flowing&&!t.reading&&e.read(0)}function C(e){var t=e._readableState;for(O("flow",t.flowing);t.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function k(e){var t=e._readableState;O("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(R,t,e))}function R(e,t){if(O("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function A(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}var T;t.exports=u,u.ReadableState=a;e("events").EventEmitter;var O,B=function(e,t){return e.listeners(t).length},L=e("./internal/streams/stream"),M=e("buffer").Buffer,N=n.Uint8Array||function(){},P=e("util");O=P&&P.debuglog?P.debuglog("stream"):function(){};var x,U,j,F=e("./internal/streams/buffer_list"),D=e("./internal/streams/destroy"),H=e("./internal/streams/state"),q=H.getHighWaterMark,K=e("../errors").codes,V=K.ERR_INVALID_ARG_TYPE,W=K.ERR_STREAM_PUSH_AFTER_EOF,$=K.ERR_METHOD_NOT_IMPLEMENTED,Q=K.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(u,L);var Y=D.errorOrDestroy,z=["error","close","destroy","pause","resume"];Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),u.prototype.destroy=D.destroy,u.prototype._undestroy=D.undestroy,u.prototype._destroy=function(e,t){t(e)},u.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=M.from(e,t),t=""),r=!0),l(this,e,t,!1,r)},u.prototype.unshift=function(e){return l(this,e,null,!0,!1)},u.prototype.isPaused=function(){return!1===this._readableState.flowing},u.prototype.setEncoding=function(t){x||(x=e("string_decoder/").StringDecoder);var r=new x(t);this._readableState.decoder=r,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=r.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var G=1073741824;u.prototype.read=function(e){O("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return O("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?k(this):g(this),null;if(e=p(e,t),0===e&&t.ended)return 0===t.length&&k(this),null;var n,i=t.needReadable;return O("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&(i=!0,O("length less than watermark",i)),t.ended||t.reading?(i=!1,O("reading or ended",i)):i&&(O("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=p(r,t))),n=e>0?I(e,t):null,null===n?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&k(this)),null!==n&&this.emit("data",n),n},u.prototype._read=function(e){Y(this,new $("_read()"))},u.prototype.pipe=function(e,t){function n(e,t){O("onunpipe"),e===h&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,o())}function i(){O("onend"),e.end()}function o(){O("cleanup"),e.removeListener("close",l),e.removeListener("finish",f),e.removeListener("drain",b),e.removeListener("error",u),e.removeListener("unpipe",n),h.removeListener("end",i),h.removeListener("end",c),h.removeListener("data",a),y=!0,!p.awaitDrain||e._writableState&&!e._writableState.needDrain||b()}function a(t){O("ondata");var r=e.write(t);O("dest.write",r),!1===r&&((1===p.pipesCount&&p.pipes===e||p.pipesCount>1&&-1!==A(p.pipes,e))&&!y&&(O("false write response, pause",p.awaitDrain),p.awaitDrain++),h.pause())}function u(t){O("onerror",t),c(),e.removeListener("error",u),0===B(e,"error")&&Y(e,t)}function l(){e.removeListener("finish",f),c()}function f(){O("onfinish"),e.removeListener("close",l),c()}function c(){O("unpipe"),h.unpipe(e)}var h=this,p=this._readableState;switch(p.pipesCount){case 0:p.pipes=e;break;case 1:p.pipes=[p.pipes,e];break;default:p.pipes.push(e)}p.pipesCount+=1,O("pipe count=%d opts=%j",p.pipesCount,t);var d=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr,g=d?i:c;p.endEmitted?r.nextTick(g):h.once("end",g),e.on("unpipe",n);var b=m(h);e.on("drain",b);var y=!1;return h.on("data",a),s(e,"error",u),e.once("close",l),e.once("finish",f),e.emit("pipe",h),p.flowing||(O("pipe resume"),h.resume()),e},u.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};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,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=A(t.pipes,e);return-1===s?this:(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r),this)},u.prototype.on=function(e,t){var n=L.prototype.on.call(this,e,t),i=this._readableState;return"data"===e?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,O("on readable",i.length,i.reading),i.length?g(this):i.reading||r.nextTick(v,this))),n},u.prototype.addListener=u.prototype.on,u.prototype.removeListener=function(e,t){var n=L.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(w,this),n},u.prototype.removeAllListeners=function(e){var t=L.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(w,this),t},u.prototype.resume=function(){var e=this._readableState;return e.flowing||(O("resume"),e.flowing=!e.readableListening,S(this,e)),e.paused=!1,this},u.prototype.pause=function(){return O("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(O("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},u.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",function(){if(O("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(i){if(O("wrapped data"),r.decoder&&(i=r.decoder.write(i)),(!r.objectMode||null!=i)&&(r.objectMode||i&&i.length)){var o=t.push(i);o||(n=!0,e.pause())}}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<z.length;o++)e.on(z[o],this.emit.bind(this,z[o]));return this._read=function(t){O("wrapped _read",t),n&&(n=!1,e.resume())},this},"function"==typeof Symbol&&(u.prototype[Symbol.asyncIterator]=function(){return void 0===U&&(U=e("./internal/streams/async_iterator")),U(this)}),Object.defineProperty(u.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(u.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(u.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),u._fromList=I,Object.defineProperty(u.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(u.from=function(t,r){return void 0===j&&(j=e("./internal/streams/from")),j(u,t,r)})}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":17,"./_stream_duplex":18,"./internal/streams/async_iterator":23, |
| 3 | "./internal/streams/buffer_list":24,"./internal/streams/destroy":25,"./internal/streams/from":27,"./internal/streams/state":29,"./internal/streams/stream":30,_process:6,buffer:3,events:4,inherits:14,"string_decoder/":33,util:2}],21:[function(e,t,r){"use strict";function n(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new l);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);h.call(this,e),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",o)}function o(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?s(this,null,null):this._flush(function(t,r){s(e,t,r)})}function s(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new c;if(e._transformState.transforming)throw new f;return e.push(null)}t.exports=i;var a=e("../errors").codes,u=a.ERR_METHOD_NOT_IMPLEMENTED,l=a.ERR_MULTIPLE_CALLBACK,f=a.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=a.ERR_TRANSFORM_WITH_LENGTH_0,h=e("./_stream_duplex");e("inherits")(i,h),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,h.prototype.push.call(this,e,t)},i.prototype._transform=function(e,t,r){r(new u("_transform()"))},i.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)}},i.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},i.prototype._destroy=function(e,t){h.prototype._destroy.call(this,e,function(e){t(e)})}},{"../errors":17,"./_stream_duplex":18,inherits:14}],22:[function(e,t,r){(function(r,n){(function(){"use strict";function i(e){var t=this;this.next=null,this.entry=null,this.finish=function(){k(t,e)}}function o(e){return B.from(e)}function s(e){return B.isBuffer(e)||e instanceof L}function a(){}function u(t,r,n){R=R||e("./_stream_duplex"),t=t||{},"boolean"!=typeof n&&(n=r instanceof R),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=P(this,t,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===t.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function l(t){R=R||e("./_stream_duplex");var r=this instanceof R;if(!r&&!A.call(l,this))return new l(t);this._writableState=new u(t,this,r),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),O.call(this)}function f(e,t){var n=new K;W(e,n),r.nextTick(t,n)}function c(e,t,n,i){var o;return null===n?o=new q:"string"==typeof n||t.objectMode||(o=new U("chunk",["string","Buffer"],n)),!o||(W(e,o),r.nextTick(i,o),!1)}function h(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=B.from(t,r)),t}function p(e,t,r,n,i,o){if(!r){var s=h(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else d(e,t,!1,a,n,i,o);return u}function d(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new H("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,n,i,o){--t.pendingcb,n?(r.nextTick(o,i),r.nextTick(C,e,t),e._writableState.errorEmitted=!0,W(e,i)):(o(i),e._writableState.errorEmitted=!0,W(e,i),C(e,t))}function b(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function y(e,t){var n=e._writableState,i=n.sync,o=n.writecb;if("function"!=typeof o)throw new F;if(b(n),t)g(e,n,i,t,o);else{var s=v(n)||e.destroyed;s||n.corked||n.bufferProcessing||!n.bufferedRequest||w(e,n),i?r.nextTick(_,e,n,s,o):_(e,n,s,o)}}function _(e,t,r,n){r||m(e,t),t.pendingcb--,n(),C(e,t)}function m(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,o=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)o[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;o.allBuffers=u,d(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new i(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,f=r.encoding,c=r.callback,h=t.objectMode?1:l.length;if(d(e,t,!1,h,l,f,c),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function v(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function S(e,t){e._final(function(r){t.pendingcb--,r&&W(e,r),t.prefinished=!0,e.emit("prefinish"),C(e,t)})}function E(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,r.nextTick(S,e,t)))}function C(e,t){var r=v(t);if(r&&(E(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function I(e,t,n){t.ending=!0,C(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function k(e,t,r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree.next=e}var R;t.exports=l,l.WritableState=u;var A,T={deprecate:e("util-deprecate")},O=e("./internal/streams/stream"),B=e("buffer").Buffer,L=n.Uint8Array||function(){},M=e("./internal/streams/destroy"),N=e("./internal/streams/state"),P=N.getHighWaterMark,x=e("../errors").codes,U=x.ERR_INVALID_ARG_TYPE,j=x.ERR_METHOD_NOT_IMPLEMENTED,F=x.ERR_MULTIPLE_CALLBACK,D=x.ERR_STREAM_CANNOT_PIPE,H=x.ERR_STREAM_DESTROYED,q=x.ERR_STREAM_NULL_VALUES,K=x.ERR_STREAM_WRITE_AFTER_END,V=x.ERR_UNKNOWN_ENCODING,W=M.errorOrDestroy;e("inherits")(l,O),u.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(u.prototype,"buffer",{get:T.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(A=Function.prototype[Symbol.hasInstance],Object.defineProperty(l,Symbol.hasInstance,{value:function(e){return!!A.call(this,e)||this===l&&(e&&e._writableState instanceof u)}})):A=function(e){return e instanceof this},l.prototype.pipe=function(){W(this,new D)},l.prototype.write=function(e,t,r){var n=this._writableState,i=!1,u=!n.objectMode&&s(e);return u&&!B.isBuffer(e)&&(e=o(e)),"function"==typeof t&&(r=t,t=null),u?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof r&&(r=a),n.ending?f(this,r):(u||c(this,n,e,r))&&(n.pendingcb++,i=p(this,n,u,e,t,r)),i},l.prototype.cork=function(){this._writableState.corked++},l.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||w(this,e))},l.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new V(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),l.prototype._write=function(e,t,r){r(new j("_write()"))},l.prototype._writev=null,l.prototype.end=function(e,t,r){var n=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||I(this,n,r),this},Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),l.prototype.destroy=M.destroy,l.prototype._undestroy=M.undestroy,l.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":17,"./_stream_duplex":18,"./internal/streams/destroy":25,"./internal/streams/state":29,"./internal/streams/stream":30,_process:6,buffer:3,inherits:14,"util-deprecate":34}],23:[function(e,t,r){(function(r){(function(){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){return{value:e,done:t}}function o(e){var t=e[f];if(null!==t){var r=e[b].read();null!==r&&(e[d]=null,e[f]=null,e[c]=null,t(i(r,!1)))}}function s(e){r.nextTick(o,e)}function a(e,t){return function(r,n){e.then(function(){t[p]?r(i(void 0,!0)):t[g](r,n)},n)}}var u,l=e("./end-of-stream"),f=Symbol("lastResolve"),c=Symbol("lastReject"),h=Symbol("error"),p=Symbol("ended"),d=Symbol("lastPromise"),g=Symbol("handlePromise"),b=Symbol("stream"),y=Object.getPrototypeOf(function(){}),_=Object.setPrototypeOf((u={get stream(){return this[b]},next:function(){var e=this,t=this[h];if(null!==t)return Promise.reject(t);if(this[p])return Promise.resolve(i(void 0,!0));if(this[b].destroyed)return new Promise(function(t,n){r.nextTick(function(){e[h]?n(e[h]):t(i(void 0,!0))})});var n,o=this[d];if(o)n=new Promise(a(o,this));else{var s=this[b].read();if(null!==s)return Promise.resolve(i(s,!1));n=new Promise(this[g])}return this[d]=n,n}},n(u,Symbol.asyncIterator,function(){return this}),n(u,"return",function(){var e=this;return new Promise(function(t,r){e[b].destroy(null,function(e){e?r(e):t(i(void 0,!0))})})}),u),y),m=function(e){var t,r=Object.create(_,(t={},n(t,b,{value:e,writable:!0}),n(t,f,{value:null,writable:!0}),n(t,c,{value:null,writable:!0}),n(t,h,{value:null,writable:!0}),n(t,p,{value:e._readableState.endEmitted,writable:!0}),n(t,g,{value:function(e,t){var n=r[b].read();n?(r[d]=null,r[f]=null,r[c]=null,e(i(n,!1))):(r[f]=e,r[c]=t)},writable:!0}),t));return r[d]=null,l(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[c];return null!==t&&(r[d]=null,r[f]=null,r[c]=null,t(e)),void(r[h]=e)}var n=r[f];null!==n&&(r[d]=null,r[f]=null,r[c]=null,n(i(void 0,!0))),r[p]=!0}),e.on("readable",s.bind(null,r)),r};t.exports=m}).call(this)}).call(this,e("_process"))},{"./end-of-stream":26,_process:6}],24:[function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function l(e,t,r){c.prototype.copy.call(e,t,r)}var f=e("buffer"),c=f.Buffer,h=e("util"),p=h.inspect,d=p&&p.custom||"inspect";t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return u(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return c.alloc(0);for(var t=c.allocUnsafe(e>>>0),r=this.head,n=0;r;)l(r.data,t,n),n+=r.data.length,r=r.next;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),e-=o,0===e){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=c.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),e-=o,0===e){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:d,value:function(e,t){return p(this,i({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:3,util:2}],25:[function(e,t,r){(function(e){(function(){"use strict";function r(t,r){var o=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(r?r(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!r&&t?o._writableState?o._writableState.errorEmitted?e.nextTick(i,o):(o._writableState.errorEmitted=!0,e.nextTick(n,o,t)):e.nextTick(n,o,t):r?(e.nextTick(i,o),r(t)):e.nextTick(i,o)}),this)}function n(e,t){s(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function o(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(e,t){e.emit("error",t)}function a(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:r,undestroy:o,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:6}],26:[function(e,t,r){"use strict";function n(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function i(){}function o(e){return e.setHeader&&"function"==typeof e.abort}function s(e,t,r){if("function"==typeof t)return s(e,null,t);t||(t={}),r=n(r||i);var u=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,f=function(){e.writable||h()},c=e._writableState&&e._writableState.finished,h=function(){l=!1,c=!0,u||r.call(e)},p=e._readableState&&e._readableState.endEmitted,d=function(){u=!1,p=!0,l||r.call(e)},g=function(t){r.call(e,t)},b=function(){var t;return u&&!p?(e._readableState&&e._readableState.ended||(t=new a),r.call(e,t)):l&&!c?(e._writableState&&e._writableState.ended||(t=new a),r.call(e,t)):void 0},y=function(){e.req.on("finish",h)};return o(e)?(e.on("complete",h),e.on("abort",b),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",f),e.on("close",f)),e.on("end",d),e.on("finish",h),!1!==t.error&&e.on("error",g),e.on("close",b),function(){e.removeListener("complete",h),e.removeListener("abort",b),e.removeListener("request",y),e.req&&e.req.removeListener("finish",h),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",h),e.removeListener("end",d),e.removeListener("error",g),e.removeListener("close",b)}}var a=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;t.exports=s},{"../../../errors":17}],27:[function(e,t,r){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],28:[function(e,t,r){"use strict";function n(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}function i(e){if(e)throw e}function o(e){return e.setHeader&&"function"==typeof e.abort}function s(t,r,i,s){s=n(s);var a=!1;t.on("close",function(){a=!0}),void 0===c&&(c=e("./end-of-stream")),c(t,{readable:r,writable:i},function(e){if(e)return s(e);a=!0,s()});var u=!1;return function(e){if(!a&&!u)return u=!0,o(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new d("pipe"))}}function a(e){e()}function u(e,t){return e.pipe(t)}function l(e){return e.length?"function"!=typeof e[e.length-1]?i:e.pop():i}function f(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,i=l(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new p("streams");var o=t.map(function(e,r){var u=r<t.length-1,l=r>0;return s(e,u,l,function(e){n||(n=e),e&&o.forEach(a),u||(o.forEach(a),i(n))})});return t.reduce(u)}var c,h=e("../../../errors").codes,p=h.ERR_MISSING_ARGS,d=h.ERR_STREAM_DESTROYED;t.exports=f},{"../../../errors":17,"./end-of-stream":26}],29:[function(e,t,r){"use strict";function n(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}function i(e,t,r,i){var s=n(t,i,r);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0){var a=i?r:"highWaterMark";throw new o(a,s)}return Math.floor(s)}return e.objectMode?16:16384}var o=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:i}},{"../../../errors":17}],30:[function(e,t,r){t.exports=e("events").EventEmitter},{events:4}],31:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js"),r.Stream=r,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"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":18,"./lib/_stream_passthrough.js":19,"./lib/_stream_readable.js":20,"./lib/_stream_transform.js":21,"./lib/_stream_writable.js":22,"./lib/internal/streams/end-of-stream.js":26,"./lib/internal/streams/pipeline.js":28}],32:[function(e,t,r){function n(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return s(e,t,r)}var o=e("buffer"),s=o.Buffer;s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=o:(n(o,r),r.Buffer=i),i.prototype=Object.create(s.prototype),n(s,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return s(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=s(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return s(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},{buffer:3}],33:[function(e,t,r){"use strict";function n(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function i(e){var t=n(e);if("string"!=typeof t&&(_.isEncoding===m||!m(e)))throw new Error("Unknown encoding: "+e);return t||e}function o(e){var t;switch(this.encoding=i(e),this.encoding){case"utf16le":this.text=h,this.end=p,t=4;break;case"utf8":this.fillLast=l,t=4;break;case"base64":this.text=d,this.end=g,t=3;break;default:return this.write=b,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=_.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e,t,r){var n=t.length-1;if(n<r)return 0;var i=s(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||-2===i?0:(i=s(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||-2===i?0:(i=s(t[n]),i>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0))}function u(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function l(e){var t=this.lastTotal-this.lastNeed,r=u(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var r=a(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function h(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function d(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function g(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function b(e){return e.toString(this.encoding)}function y(e){return e&&e.length?this.write(e):""}var _=e("safe-buffer").Buffer,m=_.isEncoding||function(e){switch(e=""+e,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}};r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=c,o.prototype.text=f,o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":32}],34:[function(e,t,r){(function(e){(function(){function r(e,t){function r(){if(!i){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var i=!1;return r}function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=r}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],35:[function(e,t,r){(function(e){(function(){function r(t){const r=e.allocUnsafe(2);return r.writeUInt8(t>>8,0),r.writeUInt8(255&t,1),r}function n(){for(let e=0;e<s;e++)a[e]=r(e)}function i(t){const r=4;let n=0,i=0;const o=e.allocUnsafe(r);do{n=t%128|0,t=t/128|0,t>0&&(n|=128),o.writeUInt8(n,i++)}while(t>0&&i<r);return t>0&&(i=0),u?o.subarray(0,i):o.slice(0,i)}function o(t){const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}const s=65536,a={},u=e.isBuffer(e.from([1,2]).subarray(0,1));t.exports={cache:a,generateCache:n,generateNumber:r,genBufVariableByteInt:i,generate4ByteBuffer:o}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:3}],36:[function(e,t,r){class n{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=n},{}],37:[function(e,t,r){const n=e("bl"),i=e("events"),o=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class u extends i{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof u?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new u).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");const i={},o=this.packet,u=this._parseString();if(null===u)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==u&&"MQIsdp"!==u)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=u,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,i.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,i.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,i.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(o.clientId=l,a("_parseConnect: packet.clientId: %s",o.clientId),i.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,a("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(i.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));o.username=n,a("_parseConnect: packet.username: %s",o.username)}if(i.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<2)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion?e.reasonCode=this._list.readUInt8(this._pos++):e.returnCode=this._list.readUInt8(this._pos++),-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,n,i,o,u,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)} |
| 4 | for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,u=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),i=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:n},5===this.settings.protocolVersion&&(l.nl=u,l.rap=o,l.rh=i),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2&&(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)),e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){e.reasonCode=this._parseByte();const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let r,n=0,i=1,o=0,u=!1;const l=this._pos?this._pos:0;for(;n<t;){if(r=this._list.readUInt8(l+n++),o+=i*(r&s.VARBYTEINT_MASK),i*=128,0==(r&s.VARBYTEINT_FIN_MASK)){u=!0;break}if(this._list.length<=n)break}return!u&&n===t&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),u=!!u&&(e?{bytes:n,value:o}:o),a("_parseVarByteNum: result: %o",u),u}_parseByte(){const e=this._list.readUInt8(this._pos);return this._pos++,a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos,r=t+e,n={};for(;this._pos<r;){const e=this._parseByte(),t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?Array.isArray(n[t])?n[t].push(this._parseByType(s.propertiesTypes[t])):(n[t]=[n[t]],n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=u},{"./constants":7,"./packet":36,bl:11,debug:12,events:4}],38:[function(e,t,r){(function(r){(function(){function n(e,t,r){switch(N("generate called"),t.cork&&(t.cork(),M(i,t)),H&&(H=!1,U()),N("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return o(e,t,r);case"connack":return s(e,t,r);case"publish":return a(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return u(e,t,r);case"subscribe":return l(e,t,r);case"suback":return f(e,t,r);case"unsubscribe":return c(e,t,r);case"unsuback":return h(e,t,r);case"pingreq":case"pingresp":return p(e,t,r);case"disconnect":return d(e,t,r);case"auth":return g(e,t,r);default:return t.emit("error",new Error("Unknown command")),!1}}function i(e){e.uncork()}function o(e,t,n){const i=e||{},o=i.protocolId||"MQTT",s=i.protocolVersion||4,a=i.will;let u=i.clean;const l=i.keepalive||0,f=i.clientId||"",c=i.username,h=i.password,p=i.properties;void 0===u&&(u=!0);let d=0;if(!o||"string"!=typeof o&&!r.isBuffer(o))return t.emit("error",new Error("Invalid protocolId")),!1;if(d+=o.length+2,3!==s&&4!==s&&5!==s)return t.emit("error",new Error("Invalid protocol version")),!1;if(d+=1,"string"!=typeof f&&!r.isBuffer(f)||!f&&4!==s||!f&&!u){if(s<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}else d+=f.length+2;if("number"!=typeof l||l<0||l>65535||l%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(d+=2,d+=1,5===s){var g=E(t,p);if(!g)return!1;d+=g.length}if(a){if("object"!=typeof a)return t.emit("error",new Error("Invalid will")),!1;if(!a.topic||"string"!=typeof a.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(d+=r.byteLength(a.topic)+2,d+=2,a.payload){if(!(a.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof a.payload?d+=r.byteLength(a.payload):d+=a.payload.length}var _={};if(5===s){if(_=E(t,a.properties),!_)return!1;d+=_.length}}let m=!1;if(null!=c){if(!A(c))return t.emit("error",new Error("Invalid username")),!1;m=!0,d+=r.byteLength(c)+2}if(null!=h){if(!m)return t.emit("error",new Error("Username is required to use password")),!1;if(!A(h))return t.emit("error",new Error("Invalid password")),!1;d+=R(h)+2}t.write(T.CONNECT_HEADER),b(t,d),S(t,o),t.write(4===s?T.VERSION4:5===s?T.VERSION5:T.VERSION3);let w=0;return w|=null!=c?T.USERNAME_MASK:0,w|=null!=h?T.PASSWORD_MASK:0,w|=a&&a.retain?T.WILL_RETAIN_MASK:0,w|=a&&a.qos?a.qos<<T.WILL_QOS_SHIFT:0,w|=a?T.WILL_FLAG_MASK:0,w|=u?T.CLEAN_SESSION_MASK:0,t.write(r.from([w])),D(t,l),5===s&&g.write(),S(t,f),a&&(5===s&&_.write(),y(t,a.topic),S(t,a.payload)),null!=c&&S(t,c),null!=h&&S(t,h),!0}function s(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=5===i?o.reasonCode:o.returnCode,a=o.properties;let u=2;if("number"!=typeof s)return t.emit("error",new Error("Invalid return code")),!1;let l=null;if(5===i){if(l=E(t,a),!l)return!1;u+=l.length}return t.write(T.CONNACK_HEADER),b(t,u),t.write(o.sessionPresent?T.SESSIONPRESENT_HEADER:B),t.write(r.from([s])),null!=l&&l.write(),!0}function a(e,t,n){N("publish: packet: %o",e);const i=n?n.protocolVersion:4,o=e||{},s=o.qos||0,a=o.retain?T.RETAIN_MASK:0,u=o.topic,l=o.payload||O,f=o.messageId,c=o.properties;let h=0;if("string"==typeof u)h+=r.byteLength(u)+2;else{if(!r.isBuffer(u))return t.emit("error",new Error("Invalid topic")),!1;h+=u.length+2}if(r.isBuffer(l)?h+=l.length:h+=r.byteLength(l),s&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;s&&(h+=2);let p=null;if(5===i){if(p=E(t,c),!p)return!1;h+=p.length}return t.write(T.PUBLISH_HEADER[s][o.dup?1:0][a?1:0]),b(t,h),D(t,R(u)),t.write(u),s>0&&D(t,f),null!=p&&p.write(),N("publish: payload: %o",l),t.write(l)}function u(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.cmd||"puback",a=o.messageId,u=o.dup&&"pubrel"===s?T.DUP_MASK:0;let l=0;const f=o.reasonCode,c=o.properties;let h=5===i?3:2;if("pubrel"===s&&(l=1),"number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;let p=null;if(5===i&&"object"==typeof c){if(p=C(t,c,n,h),!p)return!1;h+=p.length}return t.write(T.ACKS[s][l][u][0]),b(t,h),D(t,a),5===i&&t.write(r.from([f])),null!==p&&p.write(),!0}function l(e,t,n){N("subscribe: packet: ");const i=n?n.protocolVersion:4,o=e||{},s=o.dup?T.DUP_MASK:0,a=o.messageId,u=o.subscriptions,l=o.properties;let f=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;let c=null;if(5===i){if(c=E(t,l),!c)return!1;f+=c.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const n=u[e].topic,o=u[e].qos;if("string"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){const r=u[e].nl||!1;if("boolean"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;const n=u[e].rap||!1;if("boolean"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const i=u[e].rh||0;if("number"!=typeof i||i>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=r.byteLength(n)+2+1}N("subscribe: writing to stream: %o",T.SUBSCRIBE_HEADER),t.write(T.SUBSCRIBE_HEADER[1][s?1:0][0]),b(t,f),D(t,a),null!==c&&c.write();let h=!0;for(const e of u){const n=e.topic,o=e.qos,s=+e.nl,a=+e.rap,u=e.rh;let l;y(t,n),l=T.SUBSCRIBE_OPTIONS_QOS[o],5===i&&(l|=s?T.SUBSCRIBE_OPTIONS_NL:0,l|=a?T.SUBSCRIBE_OPTIONS_RAP:0,l|=u?T.SUBSCRIBE_OPTIONS_RH[u]:0),h=t.write(r.from([l]))}return h}function f(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.messageId,a=o.granted,u=o.properties;let l=0;if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;if(l+=2,"object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<a.length;e+=1){if("number"!=typeof a[e])return t.emit("error",new Error("Invalid qos vector")),!1;l+=1}let f=null;if(5===i){if(f=C(t,u,n,l),!f)return!1;l+=f.length}return t.write(T.SUBACK_HEADER),b(t,l),D(t,s),null!==f&&f.write(),t.write(r.from(a))}function c(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.messageId,a=o.dup?T.DUP_MASK:0,u=o.unsubscriptions,l=o.properties;let f=0;if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;if(f+=2,"object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;f+=r.byteLength(u[e])+2}let c=null;if(5===i){if(c=E(t,l),!c)return!1;f+=c.length}t.write(T.UNSUBSCRIBE_HEADER[1][a?1:0][0]),b(t,f),D(t,s),null!==c&&c.write();let h=!0;for(let e=0;e<u.length;e++)h=y(t,u[e]);return h}function h(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.messageId,a=o.dup?T.DUP_MASK:0,u=o.granted,l=o.properties,f=o.cmd,c=0;let h=2;if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),!1;h+=1}}let p=null;if(5===i){if(p=C(t,l,n,h),!p)return!1;h+=p.length}return t.write(T.ACKS[f][c][a][0]),b(t,h),D(t,s),null!==p&&p.write(),5===i&&t.write(r.from(u)),!0}function p(e,t,r){return t.write(T.EMPTY[e.cmd])}function d(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.reasonCode,a=o.properties;let u=5===i?1:0,l=null;if(5===i){if(l=C(t,a,n,u),!l)return!1;u+=l.length}return t.write(r.from([T.codes.disconnect<<4])),b(t,u),5===i&&t.write(r.from([s])),null!==l&&l.write(),!0}function g(e,t,n){const i=n?n.protocolVersion:4,o=e||{},s=o.reasonCode,a=o.properties;let u=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const l=C(t,a,n,u);return!!l&&(u+=l.length,t.write(r.from([T.codes.auth<<4])),b(t,u),t.write(r.from([s])),null!==l&&l.write(),!0)}function b(e,t){if(t>T.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=q[t];return r||(r=j(t),t<16384&&(q[t]=r)),N("writeVarByteInt: writing to stream: %o",r),e.write(r)}function y(e,t){const n=r.byteLength(t);return D(e,n),N("writeString: %s",t),e.write(t,"utf8")}function _(e,t,r){y(e,t),y(e,r)}function m(e,t){return N("writeNumberCached: number: %d",t),N("writeNumberCached: %o",P[t]),e.write(P[t])}function w(e,t){const r=x(t);return N("writeNumberGenerated: %o",r),e.write(r)}function v(e,t){const r=F(t);return N("write4ByteNumber: %o",r),e.write(r)}function S(e,t){"string"==typeof t?y(e,t):t?(D(e,t.length),e.write(t)):D(e,0)}function E(e,t){function n(t,n){const i=T.propertiesTypes[t];let o=0;switch(i){case"byte":if("boolean"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=2;break;case"int8":if("number"!=typeof n||n<0||n>255)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=2;break;case"binary":if(n&&null===n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=1+r.byteLength(n)+2;break;case"int16":if("number"!=typeof n||n<0||n>65535)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=3;break;case"int32":if("number"!=typeof n||n<0||n>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=5;break;case"var":if("number"!=typeof n||n<0||n>268435455)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=1+r.byteLength(j(n));break;case"string":if("string"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=3+r.byteLength(n.toString());break;case"pair":if("object"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=Object.getOwnPropertyNames(n).reduce((e,t)=>{const i=n[t];return Array.isArray(i)?e+=i.reduce((e,n)=>(e+=3+r.byteLength(t.toString())+2+r.byteLength(n.toString()),e),0):e+=3+r.byteLength(t.toString())+2+r.byteLength(n[t].toString()),e},0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${n}`)),!1}return o}if("object"!=typeof t||null!=t.length)return{length:1,write(){k(e,{},0)}};let i=0;if(t)for(const e in t){let r=0,o=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(o=n(e,s[t]),!o)return!1;r+=o}else{if(o=n(e,s),!o)return!1;r=o}if(!r)return!1;i+=r}const o=r.byteLength(j(i));return{length:o+i,write(){k(e,t,i)}}}function C(e,t,r,n){const i=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=E(e,t);if(o)for(;n+s.length>o;){const r=i.shift();if(!r||!t[r])return!1;delete t[r],s=E(e,t)}return s}function I(e,t,n){const i=T.propertiesTypes[t];switch(i){case"byte":e.write(r.from([T.properties[t]])),e.write(r.from([+n]));break;case"int8":e.write(r.from([T.properties[t]])),e.write(r.from([n]));break;case"binary":e.write(r.from([T.properties[t]])),S(e,n);break;case"int16":e.write(r.from([T.properties[t]])),D(e,n);break;case"int32":e.write(r.from([T.properties[t]])),v(e,n);break;case"var":e.write(r.from([T.properties[t]])),b(e,n);break;case"string":e.write(r.from([T.properties[t]])),y(e,n);break;case"pair":Object.getOwnPropertyNames(n).forEach(i=>{const o=n[i];Array.isArray(o)?o.forEach(n=>{e.write(r.from([T.properties[t]])),_(e,i.toString(),n.toString())}):(e.write(r.from([T.properties[t]])),_(e,i.toString(),o.toString()))});break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${n}`)),!1}}function k(e,t,r){b(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const n=t[r];if(Array.isArray(n))for(let t=0;t<n.length;t++)I(e,r,n[t]);else I(e,r,n)}}function R(e){return e?e instanceof r?e.length:r.byteLength(e):0}function A(e){return"string"==typeof e||e instanceof r}const T=e("./constants"),O=r.allocUnsafe(0),B=r.from([0]),L=e("./numbers"),M=e("process-nextick-args").nextTick,N=e("debug")("mqtt-packet:writeToStream"),P=L.cache,x=L.generateNumber,U=L.generateCache,j=L.genBufVariableByteInt,F=L.generate4ByteBuffer;let D=m,H=!0;Object.defineProperty(n,"cacheNumbers",{get:()=>D===m,set(e){e?(P&&0!==Object.keys(P).length||(H=!0),D=m):(H=!1,D=w)}});const q={};t.exports=n}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":7,"./numbers":35,buffer:3,debug:12,"process-nextick-args":16}]},{},[9]); |
no test coverage detected