node-mock-http
Advanced tools
@@ -1,1 +0,7 @@ | ||
| "use strict";const node_buffer=require("node:buffer");exports.Buffer=node_buffer.Buffer; | ||
| 'use strict'; | ||
| const node_buffer = require('node:buffer'); | ||
| exports.Buffer = node_buffer.Buffer; |
@@ -1,1 +0,1 @@ | ||
| export{Buffer}from"node:buffer"; | ||
| export { Buffer } from 'node:buffer'; |
@@ -1,1 +0,2037 @@ | ||
| "use strict";const a$1=[],l=[],x$1=typeof Uint8Array>"u"?Array:Uint8Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=i.length;t<e;++t)a$1[t]=i[t],l[i.charCodeAt(t)]=t;l[45]=62,l[95]=63;function d$1(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");n===-1&&(n=e);const r=n===e?0:4-n%4;return[n,r]}function p(t,e,n){return(e+n)*3/4-n}function toByteArray(t){let e;const n=d$1(t),r=n[0],o=n[1],f=new x$1(p(t,r,o));let h=0;const E=o>0?r-4:r;let U;for(U=0;U<E;U+=4)e=l[t.charCodeAt(U)]<<18|l[t.charCodeAt(U+1)]<<12|l[t.charCodeAt(U+2)]<<6|l[t.charCodeAt(U+3)],f[h++]=e>>16&255,f[h++]=e>>8&255,f[h++]=e&255;return o===2&&(e=l[t.charCodeAt(U)]<<2|l[t.charCodeAt(U+1)]>>4,f[h++]=e&255),o===1&&(e=l[t.charCodeAt(U)]<<10|l[t.charCodeAt(U+1)]<<4|l[t.charCodeAt(U+2)]>>2,f[h++]=e>>8&255,f[h++]=e&255),f}function u(t){return a$1[t>>18&63]+a$1[t>>12&63]+a$1[t>>6&63]+a$1[t&63]}function A$1(t,e,n){let r;const o=[];for(let f=e;f<n;f+=3)r=(t[f]<<16&16711680)+(t[f+1]<<8&65280)+(t[f+2]&255),o.push(u(r));return o.join("")}function fromByteArray(t){let e;const n=t.length,r=n%3,o=[],f=16383;for(let h=0,E=n-r;h<E;h+=f)o.push(A$1(t,h,h+f>E?E:h+f));return r===1?(e=t[n-1],o.push(a$1[e>>2]+a$1[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(a$1[e>>10]+a$1[e>>4&63]+a$1[e<<2&63]+"=")),o.join("")}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function read(t,e,n,r,o){let f,h;const E=o*8-r-1,U=(1<<E)-1,et=U>>1;let c=-7,tt=n?o-1:0;const rt=n?-1:1;let nt=t[e+tt];for(tt+=rt,f=nt&(1<<-c)-1,nt>>=-c,c+=E;c>0;)f=f*256+t[e+tt],tt+=rt,c-=8;for(h=f&(1<<-c)-1,f>>=-c,c+=r;c>0;)h=h*256+t[e+tt],tt+=rt,c-=8;if(f===0)f=1-et;else{if(f===U)return h?Number.NaN:(nt?-1:1)*Number.POSITIVE_INFINITY;h=h+Math.pow(2,r),f=f-et}return(nt?-1:1)*h*Math.pow(2,f-r)}function write(t,e,n,r,o,f){let h,E,U,et=f*8-o-1;const c=(1<<et)-1,tt=c>>1,rt=o===23?Math.pow(2,-24)-Math.pow(2,-77):0;let nt=r?0:f-1;const ot=r?1:-1,ft=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),Number.isNaN(e)||e===Number.POSITIVE_INFINITY?(E=Number.isNaN(e)?1:0,h=c):(h=Math.floor(Math.log2(e)),e*(U=Math.pow(2,-h))<1&&(h--,U*=2),e+=h+tt>=1?rt/U:rt*Math.pow(2,1-tt),e*U>=2&&(h++,U/=2),h+tt>=c?(E=0,h=c):h+tt>=1?(E=(e*U-1)*Math.pow(2,o),h=h+tt):(E=e*Math.pow(2,tt-1)*Math.pow(2,o),h=0));o>=8;)t[n+nt]=E&255,nt+=ot,E/=256,o-=8;for(h=h<<o|E,et+=o;et>0;)t[n+nt]=h&255,nt+=ot,h/=256,et-=8;t[n+nt-ot]|=ft*128}const $=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null,INSPECT_MAX_BYTES=50,I=2147483647;Buffer.TYPED_ARRAY_SUPPORT=J(),!Buffer.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This environment lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function J(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}});function w(t){if(t>I)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,Buffer.prototype),e}function Buffer(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return A(t)}return k(t,e,n)}Buffer.poolSize=8192;function k(t,e,n){if(typeof t=="string")return K(t,e);if(ArrayBuffer.isView(t))return Q(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(a(t,ArrayBuffer)||t&&a(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(a(t,SharedArrayBuffer)||t&&a(t.buffer,SharedArrayBuffer)))return T(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return Buffer.from(r,e,n);const o=Z(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return Buffer.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}Buffer.from=function(t,e,n){return k(t,e,n)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array);function C(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function z(t,e,n){return C(t),t<=0?w(t):e!==void 0?typeof n=="string"?w(t).fill(e,n):w(t).fill(e):w(t)}Buffer.alloc=function(t,e,n){return z(t,e,n)};function A(t){return C(t),w(t<0?0:b(t)|0)}Buffer.allocUnsafe=function(t){return A(t)},Buffer.allocUnsafeSlow=function(t){return A(t)};function K(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=P(t,e)|0;let r=w(n);const o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function R(t){const e=t.length<0?0:b(t.length)|0,n=w(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Q(t){if(a(t,Uint8Array)){const e=new Uint8Array(t);return T(e.buffer,e.byteOffset,e.byteLength)}return R(t)}function T(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,Buffer.prototype),r}function Z(t){if(Buffer.isBuffer(t)){const e=b(t.length)|0,n=w(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||N(t.length)?w(0):R(t);if(t.type==="Buffer"&&Array.isArray(t.data))return R(t.data)}function b(t){if(t>=I)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I.toString(16)+" bytes");return t|0}Buffer.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==Buffer.prototype},Buffer.compare=function(t,e){if(a(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),a(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let o=0,f=Math.min(n,r);o<f;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},Buffer.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return Buffer.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=Buffer.allocUnsafe(e);let o=0;for(n=0;n<t.length;++n){let f=t[n];if(a(f,Uint8Array))o+f.length>r.length?(Buffer.isBuffer(f)||(f=Buffer.from(f.buffer,f.byteOffset,f.byteLength)),f.copy(r,o)):Uint8Array.prototype.set.call(r,f,o);else if(Buffer.isBuffer(f))f.copy(r,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=f.length}return r};function P(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||a(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return H(t).length;default:{if(o)return r?-1:L(t).length;e=(""+e).toLowerCase(),o=!0}}}Buffer.byteLength=P;function v(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return cr(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return fr(this,e,n);case"latin1":case"binary":return hr(this,e,n);case"base64":return or(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return pr(this,e,n);default:{if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}}Buffer.prototype._isBuffer=!0;function B(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}Buffer.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)B(this,e,e+1);return this},Buffer.prototype.swap32=function(){const t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)B(this,e,e+3),B(this,e+1,e+2);return this},Buffer.prototype.swap64=function(){const t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)B(this,e,e+7),B(this,e+1,e+6),B(this,e+2,e+5),B(this,e+3,e+4);return this},Buffer.prototype.toString=function(){const t=this.length;return t===0?"":arguments.length===0?O(this,0,t):Reflect.apply(v,this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:Buffer.compare(this,t)===0},Buffer.prototype.inspect=function(){let t="";const e=INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},$&&(Buffer.prototype[$]=Buffer.prototype.inspect),Buffer.prototype.compare=function(t,e,n,r,o){if(a(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),r===void 0&&(r=0),o===void 0&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;let f=o-r,h=n-e;const E=Math.min(f,h),U=this.slice(r,o),et=t.slice(e,n);for(let c=0;c<E;++c)if(U[c]!==et[c]){f=U[c],h=et[c];break}return f<h?-1:h<f?1:0};function M(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,N(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=Buffer.from(e,r)),Buffer.isBuffer(e))return e.length===0?-1:F(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):F(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function F(t,e,n,r,o){let f=1,h=t.length,E=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;f=2,h/=2,E/=2,n/=2}function U(c,tt){return f===1?c[tt]:c.readUInt16BE(tt*f)}let et;if(o){let c=-1;for(et=n;et<h;et++)if(U(t,et)===U(e,c===-1?0:et-c)){if(c===-1&&(c=et),et-c+1===E)return c*f}else c!==-1&&(et-=et-c),c=-1}else for(n+E>h&&(n=h-E),et=n;et>=0;et--){let c=!0;for(let tt=0;tt<E;tt++)if(U(t,et+tt)!==U(e,tt)){c=!1;break}if(c)return et}return-1}Buffer.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},Buffer.prototype.indexOf=function(t,e,n){return M(this,t,e,n,!0)},Buffer.prototype.lastIndexOf=function(t,e,n){return M(this,t,e,n,!1)};function rr(t,e,n,r){n=Number(n)||0;const o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;const f=e.length;r>f/2&&(r=f/2);let h;for(h=0;h<r;++h){const E=Number.parseInt(e.slice(h*2,h*2+2),16);if(N(E))return h;t[n+h]=E}return h}function tr(t,e,n,r){return d(L(e,t.length-n),t,n,r)}function ir(t,e,n,r){return d(ar(e),t,n,r)}function nr(t,e,n,r){return d(H(e),t,n,r)}function er(t,e,n,r){return d(wr(e,t.length-n),t,n,r)}Buffer.prototype.write=function(t,e,n,r){if(e===void 0)r="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")r=e,n=this.length,e=0;else if(Number.isFinite(e))e=e>>>0,Number.isFinite(n)?(n=n>>>0,r===void 0&&(r="utf8")):(r=n,n=void 0);else throw new TypeError("Buffer.write(string, encoding, offset[, length]) is no longer supported");const o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let f=!1;for(;;)switch(r){case"hex":return rr(this,t,e,n);case"utf8":case"utf-8":return tr(this,t,e,n);case"ascii":case"latin1":case"binary":return ir(this,t,e,n);case"base64":return nr(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return er(this,t,e,n);default:{if(f)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),f=!0}}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function or(t,e,n){return e===0&&n===t.length?fromByteArray(t):fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const r=[];let o=e;for(;o<n;){const f=t[o];let h=null,E=f>239?4:f>223?3:f>191?2:1;if(o+E<=n){let U,et,c,tt;switch(E){case 1:{f<128&&(h=f);break}case 2:{U=t[o+1],(U&192)===128&&(tt=(f&31)<<6|U&63,tt>127&&(h=tt));break}case 3:{U=t[o+1],et=t[o+2],(U&192)===128&&(et&192)===128&&(tt=(f&15)<<12|(U&63)<<6|et&63,tt>2047&&(tt<55296||tt>57343)&&(h=tt));break}case 4:U=t[o+1],et=t[o+2],c=t[o+3],(U&192)===128&&(et&192)===128&&(c&192)===128&&(tt=(f&15)<<18|(U&63)<<12|(et&63)<<6|c&63,tt>65535&&tt<1114112&&(h=tt))}}h===null?(h=65533,E=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|h&1023),r.push(h),o+=E}return ur(r)}const D=4096;function ur(t){const e=t.length;if(e<=D)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=D));return n}function fr(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function hr(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function cr(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let f=e;f<n;++f)o+=xr[t[f]];return o}function pr(t,e,n){const r=t.slice(e,n);let o="";for(let f=0;f<r.length-1;f+=2)o+=String.fromCharCode(r[f]+r[f+1]*256);return o}Buffer.prototype.slice=function(t,e){const n=this.length;t=Math.trunc(t),e=e===void 0?n:Math.trunc(e),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,Buffer.prototype),r};function s(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||s(t,e,this.length);let r=this[t],o=1,f=0;for(;++f<e&&(o*=256);)r+=this[t+f]*o;return r},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||s(t,e,this.length);let r=this[t+--e],o=1;for(;e>0&&(o*=256);)r+=this[t+--e]*o;return r},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function(t,e){return t=t>>>0,e||s(t,1,this.length),this[t]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||s(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||s(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||s(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||s(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readBigUInt64LE=x(function(t){t=t>>>0,m(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&g(t,this.length-8);const r=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))}),Buffer.prototype.readBigUInt64BE=x(function(t){t=t>>>0,m(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&g(t,this.length-8);const r=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(o)}),Buffer.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||s(t,e,this.length);let r=this[t],o=1,f=0;for(;++f<e&&(o*=256);)r+=this[t+f]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},Buffer.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||s(t,e,this.length);let r=e,o=1,f=this[t+--r];for(;r>0&&(o*=256);)f+=this[t+--r]*o;return o*=128,f>=o&&(f-=Math.pow(2,8*e)),f},Buffer.prototype.readInt8=function(t,e){return t=t>>>0,e||s(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,e){t=t>>>0,e||s(t,2,this.length);const n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},Buffer.prototype.readInt16BE=function(t,e){t=t>>>0,e||s(t,2,this.length);const n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},Buffer.prototype.readInt32LE=function(t,e){return t=t>>>0,e||s(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t=t>>>0,e||s(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readBigInt64LE=x(function(t){t=t>>>0,m(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&g(t,this.length-8);const r=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),Buffer.prototype.readBigInt64BE=x(function(t){t=t>>>0,m(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&g(t,this.length-8);const r=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)}),Buffer.prototype.readFloatLE=function(t,e){return t=t>>>0,e||s(t,4,this.length),read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t=t>>>0,e||s(t,4,this.length),read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||s(t,8,this.length),read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||s(t,8,this.length),read(this,t,!1,52,8)};function y(t,e,n,r,o,f){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<f)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e=e>>>0,n=n>>>0,!r){const h=Math.pow(2,8*n)-1;y(this,t,e,n,h,0)}let o=1,f=0;for(this[e]=t&255;++f<n&&(o*=256);)this[e+f]=t/o&255;return e+n},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e=e>>>0,n=n>>>0,!r){const h=Math.pow(2,8*n)-1;y(this,t,e,n,h,0)}let o=n-1,f=1;for(this[e+o]=t&255;--o>=0&&(f*=256);)this[e+o]=t/f&255;return e+n},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,1,255,0),this[e]=t&255,e+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function G(t,e,n,r,o){X(e,r,o,t,n,7);let f=Number(e&BigInt(4294967295));t[n++]=f,f=f>>8,t[n++]=f,f=f>>8,t[n++]=f,f=f>>8,t[n++]=f;let h=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=h,h=h>>8,t[n++]=h,h=h>>8,t[n++]=h,h=h>>8,t[n++]=h,n}function Y(t,e,n,r,o){X(e,r,o,t,n,7);let f=Number(e&BigInt(4294967295));t[n+7]=f,f=f>>8,t[n+6]=f,f=f>>8,t[n+5]=f,f=f>>8,t[n+4]=f;let h=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=h,h=h>>8,t[n+2]=h,h=h>>8,t[n+1]=h,h=h>>8,t[n]=h,n+8}Buffer.prototype.writeBigUInt64LE=x(function(t,e=0){return G(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),Buffer.prototype.writeBigUInt64BE=x(function(t,e=0){return Y(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),Buffer.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e=e>>>0,!r){const E=Math.pow(2,8*n-1);y(this,t,e,n,E-1,-E)}let o=0,f=1,h=0;for(this[e]=t&255;++o<n&&(f*=256);)t<0&&h===0&&this[e+o-1]!==0&&(h=1),this[e+o]=Math.trunc(t/f)-h&255;return e+n},Buffer.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e=e>>>0,!r){const E=Math.pow(2,8*n-1);y(this,t,e,n,E-1,-E)}let o=n-1,f=1,h=0;for(this[e+o]=t&255;--o>=0&&(f*=256);)t<0&&h===0&&this[e+o+1]!==0&&(h=1),this[e+o]=Math.trunc(t/f)-h&255;return e+n},Buffer.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},Buffer.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},Buffer.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||y(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},Buffer.prototype.writeBigInt64LE=x(function(t,e=0){return G(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),Buffer.prototype.writeBigInt64BE=x(function(t,e=0){return Y(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function W(t,e,n,r,o,f){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function q(t,e,n,r,o){return e=+e,n=n>>>0,o||W(t,e,n,4),write(t,e,n,r,23,4),n+4}Buffer.prototype.writeFloatLE=function(t,e,n){return q(this,t,e,!0,n)},Buffer.prototype.writeFloatBE=function(t,e,n){return q(this,t,e,!1,n)};function V(t,e,n,r,o){return e=+e,n=n>>>0,o||W(t,e,n,8),write(t,e,n,r,52,8),n+8}Buffer.prototype.writeDoubleLE=function(t,e,n){return V(this,t,e,!0,n)},Buffer.prototype.writeDoubleBE=function(t,e,n){return V(this,t,e,!1,n)},Buffer.prototype.copy=function(t,e,n,r){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!r&&r!==0&&(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const o=r-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},Buffer.prototype.fill=function(t,e,n,r){if(typeof t=="string"){if(typeof e=="string"?(r=e,e=0,n=this.length):typeof n=="string"&&(r=n,n=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!Buffer.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(t.length===1){const f=t.charCodeAt(0);(r==="utf8"&&f<128||r==="latin1")&&(t=f)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{const f=Buffer.isBuffer(t)?t:Buffer.from(t,r),h=f.length;if(h===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=f[o%h]}return this};const _={};function S(t,e,n){_[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:Reflect.apply(e,this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(r){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:r,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}S("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),S("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),S("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=j(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=j(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function j(t){let e="",n=t.length;const r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function lr(t,e,n){m(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&g(e,t.length-(n+1))}function X(t,e,n,r,o,f){if(t>n||t<e){const h=typeof e=="bigint"?"n":"";let E;throw E=e===0||e===BigInt(0)?`>= 0${h} and < 2${h} ** ${(f+1)*8}${h}`:`>= -(2${h} ** ${(f+1)*8-1}${h}) and < 2 ** ${(f+1)*8-1}${h}`,new _.ERR_OUT_OF_RANGE("value",E,t)}lr(r,o,f)}function m(t,e){if(typeof t!="number")throw new _.ERR_INVALID_ARG_TYPE(e,"number",t)}function g(t,e,n){throw Math.floor(t)!==t?(m(t,n),new _.ERR_OUT_OF_RANGE("offset","an integer",t)):e<0?new _.ERR_BUFFER_OUT_OF_BOUNDS:new _.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}const sr=/[^\w+/-]/g;function yr(t){if(t=t.split("=")[0],t=t.trim().replace(sr,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function L(t,e){e=e||Number.POSITIVE_INFINITY;let n;const r=t.length;let o=null;const f=[];for(let h=0;h<r;++h){if(n=t.charCodeAt(h),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&f.push(239,191,189);continue}else if(h+1===r){(e-=3)>-1&&f.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&f.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&f.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;f.push(n)}else if(n<2048){if((e-=2)<0)break;f.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;f.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;f.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return f}function ar(t){const e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function wr(t,e){let n,r,o;const f=[];for(let h=0;h<t.length&&!((e-=2)<0);++h)n=t.charCodeAt(h),r=n>>8,o=n%256,f.push(o,r);return f}function H(t){return toByteArray(yr(t))}function d(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function a(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function N(t){return t!==t}const xr=function(){const t="0123456789abcdef",e=Array.from({length:256});for(let n=0;n<16;++n){const r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e}();function x(t){return typeof BigInt>"u"?Br:t}function Br(){throw new Error("BigInt not supported")}exports.Buffer=Buffer; | ||
| 'use strict'; | ||
| const lookup = []; | ||
| const revLookup = []; | ||
| const Arr = typeof Uint8Array === "undefined" ? Array : Uint8Array; | ||
| const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| for (let i = 0, len = code.length; i < len; ++i) { | ||
| lookup[i] = code[i]; | ||
| revLookup[code.charCodeAt(i)] = i; | ||
| } | ||
| revLookup["-".charCodeAt(0)] = 62; | ||
| revLookup["_".charCodeAt(0)] = 63; | ||
| function getLens(b64) { | ||
| const len = b64.length; | ||
| if (len % 4 > 0) { | ||
| throw new Error("Invalid string. Length must be a multiple of 4"); | ||
| } | ||
| let validLen = b64.indexOf("="); | ||
| if (validLen === -1) { | ||
| validLen = len; | ||
| } | ||
| const placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; | ||
| return [validLen, placeHoldersLen]; | ||
| } | ||
| function _byteLength(b64, validLen, placeHoldersLen) { | ||
| return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; | ||
| } | ||
| function toByteArray(b64) { | ||
| let tmp; | ||
| const lens = getLens(b64); | ||
| const validLen = lens[0]; | ||
| const placeHoldersLen = lens[1]; | ||
| const arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); | ||
| let curByte = 0; | ||
| const len = placeHoldersLen > 0 ? validLen - 4 : validLen; | ||
| let i; | ||
| for (i = 0; i < len; i += 4) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; | ||
| arr[curByte++] = tmp >> 16 & 255; | ||
| arr[curByte++] = tmp >> 8 & 255; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| if (placeHoldersLen === 2) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| if (placeHoldersLen === 1) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; | ||
| arr[curByte++] = tmp >> 8 & 255; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| return arr; | ||
| } | ||
| function tripletToBase64(num) { | ||
| return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; | ||
| } | ||
| function encodeChunk(uint8, start, end) { | ||
| let tmp; | ||
| const output = []; | ||
| for (let i = start; i < end; i += 3) { | ||
| tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255); | ||
| output.push(tripletToBase64(tmp)); | ||
| } | ||
| return output.join(""); | ||
| } | ||
| function fromByteArray(uint8) { | ||
| let tmp; | ||
| const len = uint8.length; | ||
| const extraBytes = len % 3; | ||
| const parts = []; | ||
| const maxChunkLength = 16383; | ||
| for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { | ||
| parts.push( | ||
| encodeChunk( | ||
| uint8, | ||
| i, | ||
| i + maxChunkLength > len2 ? len2 : i + maxChunkLength | ||
| ) | ||
| ); | ||
| } | ||
| if (extraBytes === 1) { | ||
| tmp = uint8[len - 1]; | ||
| parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="); | ||
| } else if (extraBytes === 2) { | ||
| tmp = (uint8[len - 2] << 8) + uint8[len - 1]; | ||
| parts.push( | ||
| lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" | ||
| ); | ||
| } | ||
| return parts.join(""); | ||
| } | ||
| /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
| function read(buffer, offset, isLE, mLen, nBytes) { | ||
| let e, m; | ||
| const eLen = nBytes * 8 - mLen - 1; | ||
| const eMax = (1 << eLen) - 1; | ||
| const eBias = eMax >> 1; | ||
| let nBits = -7; | ||
| let i = isLE ? nBytes - 1 : 0; | ||
| const d = isLE ? -1 : 1; | ||
| let s = buffer[offset + i]; | ||
| i += d; | ||
| e = s & (1 << -nBits) - 1; | ||
| s >>= -nBits; | ||
| nBits += eLen; | ||
| while (nBits > 0) { | ||
| e = e * 256 + buffer[offset + i]; | ||
| i += d; | ||
| nBits -= 8; | ||
| } | ||
| m = e & (1 << -nBits) - 1; | ||
| e >>= -nBits; | ||
| nBits += mLen; | ||
| while (nBits > 0) { | ||
| m = m * 256 + buffer[offset + i]; | ||
| i += d; | ||
| nBits -= 8; | ||
| } | ||
| if (e === 0) { | ||
| e = 1 - eBias; | ||
| } else if (e === eMax) { | ||
| return m ? Number.NaN : (s ? -1 : 1) * Number.POSITIVE_INFINITY; | ||
| } else { | ||
| m = m + Math.pow(2, mLen); | ||
| e = e - eBias; | ||
| } | ||
| return (s ? -1 : 1) * m * Math.pow(2, e - mLen); | ||
| } | ||
| function write(buffer, value, offset, isLE, mLen, nBytes) { | ||
| let e, m, c; | ||
| let eLen = nBytes * 8 - mLen - 1; | ||
| const eMax = (1 << eLen) - 1; | ||
| const eBias = eMax >> 1; | ||
| const rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; | ||
| let i = isLE ? 0 : nBytes - 1; | ||
| const d = isLE ? 1 : -1; | ||
| const s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; | ||
| value = Math.abs(value); | ||
| if (Number.isNaN(value) || value === Number.POSITIVE_INFINITY) { | ||
| m = Number.isNaN(value) ? 1 : 0; | ||
| e = eMax; | ||
| } else { | ||
| e = Math.floor(Math.log2(value)); | ||
| if (value * (c = Math.pow(2, -e)) < 1) { | ||
| e--; | ||
| c *= 2; | ||
| } | ||
| value += e + eBias >= 1 ? rt / c : rt * Math.pow(2, 1 - eBias); | ||
| if (value * c >= 2) { | ||
| e++; | ||
| c /= 2; | ||
| } | ||
| if (e + eBias >= eMax) { | ||
| m = 0; | ||
| e = eMax; | ||
| } else if (e + eBias >= 1) { | ||
| m = (value * c - 1) * Math.pow(2, mLen); | ||
| e = e + eBias; | ||
| } else { | ||
| m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); | ||
| e = 0; | ||
| } | ||
| } | ||
| while (mLen >= 8) { | ||
| buffer[offset + i] = m & 255; | ||
| i += d; | ||
| m /= 256; | ||
| mLen -= 8; | ||
| } | ||
| e = e << mLen | m; | ||
| eLen += mLen; | ||
| while (eLen > 0) { | ||
| buffer[offset + i] = e & 255; | ||
| i += d; | ||
| e /= 256; | ||
| eLen -= 8; | ||
| } | ||
| buffer[offset + i - d] |= s * 128; | ||
| } | ||
| /*! | ||
| * The buffer module from node.js, for the browser. | ||
| * | ||
| * @author Feross Aboukhadijeh <https://feross.org> | ||
| * @license MIT | ||
| */ | ||
| const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; | ||
| const INSPECT_MAX_BYTES = 50; | ||
| const K_MAX_LENGTH = 2147483647; | ||
| Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); | ||
| if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { | ||
| console.error( | ||
| "This environment lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support." | ||
| ); | ||
| } | ||
| function typedArraySupport() { | ||
| try { | ||
| const arr = new Uint8Array(1); | ||
| const proto = { | ||
| foo: function() { | ||
| return 42; | ||
| } | ||
| }; | ||
| Object.setPrototypeOf(proto, Uint8Array.prototype); | ||
| Object.setPrototypeOf(arr, proto); | ||
| return arr.foo() === 42; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| Object.defineProperty(Buffer.prototype, "parent", { | ||
| enumerable: true, | ||
| get: function() { | ||
| if (!Buffer.isBuffer(this)) { | ||
| return; | ||
| } | ||
| return this.buffer; | ||
| } | ||
| }); | ||
| Object.defineProperty(Buffer.prototype, "offset", { | ||
| enumerable: true, | ||
| get: function() { | ||
| if (!Buffer.isBuffer(this)) { | ||
| return; | ||
| } | ||
| return this.byteOffset; | ||
| } | ||
| }); | ||
| function createBuffer(length) { | ||
| if (length > K_MAX_LENGTH) { | ||
| throw new RangeError( | ||
| 'The value "' + length + '" is invalid for option "size"' | ||
| ); | ||
| } | ||
| const buf = new Uint8Array(length); | ||
| Object.setPrototypeOf(buf, Buffer.prototype); | ||
| return buf; | ||
| } | ||
| function Buffer(arg, encodingOrOffset, length) { | ||
| if (typeof arg === "number") { | ||
| if (typeof encodingOrOffset === "string") { | ||
| throw new TypeError( | ||
| 'The "string" argument must be of type string. Received type number' | ||
| ); | ||
| } | ||
| return allocUnsafe(arg); | ||
| } | ||
| return from(arg, encodingOrOffset, length); | ||
| } | ||
| Buffer.poolSize = 8192; | ||
| function from(value, encodingOrOffset, length) { | ||
| if (typeof value === "string") { | ||
| return fromString(value, encodingOrOffset); | ||
| } | ||
| if (ArrayBuffer.isView(value)) { | ||
| return fromArrayView(value); | ||
| } | ||
| if (value == null) { | ||
| throw new TypeError( | ||
| "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value | ||
| ); | ||
| } | ||
| if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { | ||
| return fromArrayBuffer(value, encodingOrOffset, length); | ||
| } | ||
| if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { | ||
| return fromArrayBuffer(value, encodingOrOffset, length); | ||
| } | ||
| if (typeof value === "number") { | ||
| throw new TypeError( | ||
| 'The "value" argument must not be of type number. Received type number' | ||
| ); | ||
| } | ||
| const valueOf = value.valueOf && value.valueOf(); | ||
| if (valueOf != null && valueOf !== value) { | ||
| return Buffer.from(valueOf, encodingOrOffset, length); | ||
| } | ||
| const b = fromObject(value); | ||
| if (b) { | ||
| return b; | ||
| } | ||
| if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { | ||
| return Buffer.from( | ||
| value[Symbol.toPrimitive]("string"), | ||
| encodingOrOffset, | ||
| length | ||
| ); | ||
| } | ||
| throw new TypeError( | ||
| "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value | ||
| ); | ||
| } | ||
| Buffer.from = function(value, encodingOrOffset, length) { | ||
| return from(value, encodingOrOffset, length); | ||
| }; | ||
| Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); | ||
| Object.setPrototypeOf(Buffer, Uint8Array); | ||
| function assertSize(size) { | ||
| if (typeof size !== "number") { | ||
| throw new TypeError('"size" argument must be of type number'); | ||
| } else if (size < 0) { | ||
| throw new RangeError( | ||
| 'The value "' + size + '" is invalid for option "size"' | ||
| ); | ||
| } | ||
| } | ||
| function alloc(size, fill2, encoding) { | ||
| assertSize(size); | ||
| if (size <= 0) { | ||
| return createBuffer(size); | ||
| } | ||
| if (fill2 !== undefined) { | ||
| return typeof encoding === "string" ? createBuffer(size).fill(fill2, encoding) : createBuffer(size).fill(fill2); | ||
| } | ||
| return createBuffer(size); | ||
| } | ||
| Buffer.alloc = function(size, fill2, encoding) { | ||
| return alloc(size, fill2, encoding); | ||
| }; | ||
| function allocUnsafe(size) { | ||
| assertSize(size); | ||
| return createBuffer(size < 0 ? 0 : checked(size) | 0); | ||
| } | ||
| Buffer.allocUnsafe = function(size) { | ||
| return allocUnsafe(size); | ||
| }; | ||
| Buffer.allocUnsafeSlow = function(size) { | ||
| return allocUnsafe(size); | ||
| }; | ||
| function fromString(string, encoding) { | ||
| if (typeof encoding !== "string" || encoding === "") { | ||
| encoding = "utf8"; | ||
| } | ||
| if (!Buffer.isEncoding(encoding)) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| const length = byteLength(string, encoding) | 0; | ||
| let buf = createBuffer(length); | ||
| const actual = buf.write(string, encoding); | ||
| if (actual !== length) { | ||
| buf = buf.slice(0, actual); | ||
| } | ||
| return buf; | ||
| } | ||
| function fromArrayLike(array) { | ||
| const length = array.length < 0 ? 0 : checked(array.length) | 0; | ||
| const buf = createBuffer(length); | ||
| for (let i = 0; i < length; i += 1) { | ||
| buf[i] = array[i] & 255; | ||
| } | ||
| return buf; | ||
| } | ||
| function fromArrayView(arrayView) { | ||
| if (isInstance(arrayView, Uint8Array)) { | ||
| const copy2 = new Uint8Array(arrayView); | ||
| return fromArrayBuffer(copy2.buffer, copy2.byteOffset, copy2.byteLength); | ||
| } | ||
| return fromArrayLike(arrayView); | ||
| } | ||
| function fromArrayBuffer(array, byteOffset, length) { | ||
| if (byteOffset < 0 || array.byteLength < byteOffset) { | ||
| throw new RangeError('"offset" is outside of buffer bounds'); | ||
| } | ||
| if (array.byteLength < byteOffset + (length || 0)) { | ||
| throw new RangeError('"length" is outside of buffer bounds'); | ||
| } | ||
| let buf; | ||
| if (byteOffset === undefined && length === undefined) { | ||
| buf = new Uint8Array(array); | ||
| } else if (length === undefined) { | ||
| buf = new Uint8Array(array, byteOffset); | ||
| } else { | ||
| buf = new Uint8Array(array, byteOffset, length); | ||
| } | ||
| Object.setPrototypeOf(buf, Buffer.prototype); | ||
| return buf; | ||
| } | ||
| function fromObject(obj) { | ||
| if (Buffer.isBuffer(obj)) { | ||
| const len = checked(obj.length) | 0; | ||
| const buf = createBuffer(len); | ||
| if (buf.length === 0) { | ||
| return buf; | ||
| } | ||
| obj.copy(buf, 0, 0, len); | ||
| return buf; | ||
| } | ||
| if (obj.length !== undefined) { | ||
| if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { | ||
| return createBuffer(0); | ||
| } | ||
| return fromArrayLike(obj); | ||
| } | ||
| if (obj.type === "Buffer" && Array.isArray(obj.data)) { | ||
| return fromArrayLike(obj.data); | ||
| } | ||
| } | ||
| function checked(length) { | ||
| if (length >= K_MAX_LENGTH) { | ||
| throw new RangeError( | ||
| "Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes" | ||
| ); | ||
| } | ||
| return length | 0; | ||
| } | ||
| Buffer.isBuffer = function isBuffer(b) { | ||
| return b != null && b._isBuffer === true && b !== Buffer.prototype; | ||
| }; | ||
| Buffer.compare = function compare(a, b) { | ||
| if (isInstance(a, Uint8Array)) { | ||
| a = Buffer.from(a, a.offset, a.byteLength); | ||
| } | ||
| if (isInstance(b, Uint8Array)) { | ||
| b = Buffer.from(b, b.offset, b.byteLength); | ||
| } | ||
| if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { | ||
| throw new TypeError( | ||
| 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' | ||
| ); | ||
| } | ||
| if (a === b) { | ||
| return 0; | ||
| } | ||
| let x = a.length; | ||
| let y = b.length; | ||
| for (let i = 0, len = Math.min(x, y); i < len; ++i) { | ||
| if (a[i] !== b[i]) { | ||
| x = a[i]; | ||
| y = b[i]; | ||
| break; | ||
| } | ||
| } | ||
| if (x < y) { | ||
| return -1; | ||
| } | ||
| if (y < x) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| Buffer.isEncoding = function isEncoding(encoding) { | ||
| switch (String(encoding).toLowerCase()) { | ||
| case "hex": | ||
| case "utf8": | ||
| case "utf-8": | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": | ||
| case "base64": | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return true; | ||
| } | ||
| default: { | ||
| return false; | ||
| } | ||
| } | ||
| }; | ||
| Buffer.concat = function concat(list, length) { | ||
| if (!Array.isArray(list)) { | ||
| throw new TypeError('"list" argument must be an Array of Buffers'); | ||
| } | ||
| if (list.length === 0) { | ||
| return Buffer.alloc(0); | ||
| } | ||
| let i; | ||
| if (length === undefined) { | ||
| length = 0; | ||
| for (i = 0; i < list.length; ++i) { | ||
| length += list[i].length; | ||
| } | ||
| } | ||
| const buffer = Buffer.allocUnsafe(length); | ||
| let pos = 0; | ||
| for (i = 0; i < list.length; ++i) { | ||
| let buf = list[i]; | ||
| if (isInstance(buf, Uint8Array)) { | ||
| if (pos + buf.length > buffer.length) { | ||
| if (!Buffer.isBuffer(buf)) { | ||
| buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| } | ||
| buf.copy(buffer, pos); | ||
| } else { | ||
| Uint8Array.prototype.set.call(buffer, buf, pos); | ||
| } | ||
| } else if (Buffer.isBuffer(buf)) { | ||
| buf.copy(buffer, pos); | ||
| } else { | ||
| throw new TypeError('"list" argument must be an Array of Buffers'); | ||
| } | ||
| pos += buf.length; | ||
| } | ||
| return buffer; | ||
| }; | ||
| function byteLength(string, encoding) { | ||
| if (Buffer.isBuffer(string)) { | ||
| return string.length; | ||
| } | ||
| if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { | ||
| return string.byteLength; | ||
| } | ||
| if (typeof string !== "string") { | ||
| throw new TypeError( | ||
| 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string | ||
| ); | ||
| } | ||
| const len = string.length; | ||
| const mustMatch = arguments.length > 2 && arguments[2] === true; | ||
| if (!mustMatch && len === 0) { | ||
| return 0; | ||
| } | ||
| let loweredCase = false; | ||
| for (; ; ) { | ||
| switch (encoding) { | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": { | ||
| return len; | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8ToBytes(string).length; | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return len * 2; | ||
| } | ||
| case "hex": { | ||
| return len >>> 1; | ||
| } | ||
| case "base64": { | ||
| return base64ToBytes(string).length; | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| return mustMatch ? -1 : utf8ToBytes(string).length; | ||
| } | ||
| encoding = ("" + encoding).toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Buffer.byteLength = byteLength; | ||
| function slowToString(encoding, start, end) { | ||
| let loweredCase = false; | ||
| if (start === undefined || start < 0) { | ||
| start = 0; | ||
| } | ||
| if (start > this.length) { | ||
| return ""; | ||
| } | ||
| if (end === undefined || end > this.length) { | ||
| end = this.length; | ||
| } | ||
| if (end <= 0) { | ||
| return ""; | ||
| } | ||
| end >>>= 0; | ||
| start >>>= 0; | ||
| if (end <= start) { | ||
| return ""; | ||
| } | ||
| if (!encoding) { | ||
| encoding = "utf8"; | ||
| } | ||
| while (true) { | ||
| switch (encoding) { | ||
| case "hex": { | ||
| return hexSlice(this, start, end); | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8Slice(this, start, end); | ||
| } | ||
| case "ascii": { | ||
| return asciiSlice(this, start, end); | ||
| } | ||
| case "latin1": | ||
| case "binary": { | ||
| return latin1Slice(this, start, end); | ||
| } | ||
| case "base64": { | ||
| return base64Slice(this, start, end); | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return utf16leSlice(this, start, end); | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| encoding = (encoding + "").toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Buffer.prototype._isBuffer = true; | ||
| function swap(b, n, m) { | ||
| const i = b[n]; | ||
| b[n] = b[m]; | ||
| b[m] = i; | ||
| } | ||
| Buffer.prototype.swap16 = function swap16() { | ||
| const len = this.length; | ||
| if (len % 2 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 16-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 2) { | ||
| swap(this, i, i + 1); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.swap32 = function swap32() { | ||
| const len = this.length; | ||
| if (len % 4 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 32-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 4) { | ||
| swap(this, i, i + 3); | ||
| swap(this, i + 1, i + 2); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.swap64 = function swap64() { | ||
| const len = this.length; | ||
| if (len % 8 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 64-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 8) { | ||
| swap(this, i, i + 7); | ||
| swap(this, i + 1, i + 6); | ||
| swap(this, i + 2, i + 5); | ||
| swap(this, i + 3, i + 4); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.toString = function toString() { | ||
| const length = this.length; | ||
| if (length === 0) { | ||
| return ""; | ||
| } | ||
| if (arguments.length === 0) { | ||
| return utf8Slice(this, 0, length); | ||
| } | ||
| return Reflect.apply(slowToString, this, arguments); | ||
| }; | ||
| Buffer.prototype.toLocaleString = Buffer.prototype.toString; | ||
| Buffer.prototype.equals = function equals(b) { | ||
| if (!Buffer.isBuffer(b)) { | ||
| throw new TypeError("Argument must be a Buffer"); | ||
| } | ||
| if (this === b) { | ||
| return true; | ||
| } | ||
| return Buffer.compare(this, b) === 0; | ||
| }; | ||
| Buffer.prototype.inspect = function inspect() { | ||
| let str = ""; | ||
| const max = INSPECT_MAX_BYTES; | ||
| str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); | ||
| if (this.length > max) { | ||
| str += " ... "; | ||
| } | ||
| return "<Buffer " + str + ">"; | ||
| }; | ||
| if (customInspectSymbol) { | ||
| Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; | ||
| } | ||
| Buffer.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) { | ||
| if (isInstance(target, Uint8Array)) { | ||
| target = Buffer.from(target, target.offset, target.byteLength); | ||
| } | ||
| if (!Buffer.isBuffer(target)) { | ||
| throw new TypeError( | ||
| 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target | ||
| ); | ||
| } | ||
| if (start === undefined) { | ||
| start = 0; | ||
| } | ||
| if (end === undefined) { | ||
| end = target ? target.length : 0; | ||
| } | ||
| if (thisStart === undefined) { | ||
| thisStart = 0; | ||
| } | ||
| if (thisEnd === undefined) { | ||
| thisEnd = this.length; | ||
| } | ||
| if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { | ||
| throw new RangeError("out of range index"); | ||
| } | ||
| if (thisStart >= thisEnd && start >= end) { | ||
| return 0; | ||
| } | ||
| if (thisStart >= thisEnd) { | ||
| return -1; | ||
| } | ||
| if (start >= end) { | ||
| return 1; | ||
| } | ||
| start >>>= 0; | ||
| end >>>= 0; | ||
| thisStart >>>= 0; | ||
| thisEnd >>>= 0; | ||
| if (this === target) { | ||
| return 0; | ||
| } | ||
| let x = thisEnd - thisStart; | ||
| let y = end - start; | ||
| const len = Math.min(x, y); | ||
| const thisCopy = this.slice(thisStart, thisEnd); | ||
| const targetCopy = target.slice(start, end); | ||
| for (let i = 0; i < len; ++i) { | ||
| if (thisCopy[i] !== targetCopy[i]) { | ||
| x = thisCopy[i]; | ||
| y = targetCopy[i]; | ||
| break; | ||
| } | ||
| } | ||
| if (x < y) { | ||
| return -1; | ||
| } | ||
| if (y < x) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | ||
| if (buffer.length === 0) { | ||
| return -1; | ||
| } | ||
| if (typeof byteOffset === "string") { | ||
| encoding = byteOffset; | ||
| byteOffset = 0; | ||
| } else if (byteOffset > 2147483647) { | ||
| byteOffset = 2147483647; | ||
| } else if (byteOffset < -2147483648) { | ||
| byteOffset = -2147483648; | ||
| } | ||
| byteOffset = +byteOffset; | ||
| if (numberIsNaN(byteOffset)) { | ||
| byteOffset = dir ? 0 : buffer.length - 1; | ||
| } | ||
| if (byteOffset < 0) { | ||
| byteOffset = buffer.length + byteOffset; | ||
| } | ||
| if (byteOffset >= buffer.length) { | ||
| if (dir) { | ||
| return -1; | ||
| } else { | ||
| byteOffset = buffer.length - 1; | ||
| } | ||
| } else if (byteOffset < 0) { | ||
| if (dir) { | ||
| byteOffset = 0; | ||
| } else { | ||
| return -1; | ||
| } | ||
| } | ||
| if (typeof val === "string") { | ||
| val = Buffer.from(val, encoding); | ||
| } | ||
| if (Buffer.isBuffer(val)) { | ||
| if (val.length === 0) { | ||
| return -1; | ||
| } | ||
| return arrayIndexOf(buffer, val, byteOffset, encoding, dir); | ||
| } else if (typeof val === "number") { | ||
| val = val & 255; | ||
| if (typeof Uint8Array.prototype.indexOf === "function") { | ||
| return dir ? Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) : Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); | ||
| } | ||
| return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); | ||
| } | ||
| throw new TypeError("val must be string, number or Buffer"); | ||
| } | ||
| function arrayIndexOf(arr, val, byteOffset, encoding, dir) { | ||
| let indexSize = 1; | ||
| let arrLength = arr.length; | ||
| let valLength = val.length; | ||
| if (encoding !== undefined) { | ||
| encoding = String(encoding).toLowerCase(); | ||
| if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { | ||
| if (arr.length < 2 || val.length < 2) { | ||
| return -1; | ||
| } | ||
| indexSize = 2; | ||
| arrLength /= 2; | ||
| valLength /= 2; | ||
| byteOffset /= 2; | ||
| } | ||
| } | ||
| function read(buf, i2) { | ||
| return indexSize === 1 ? buf[i2] : buf.readUInt16BE(i2 * indexSize); | ||
| } | ||
| let i; | ||
| if (dir) { | ||
| let foundIndex = -1; | ||
| for (i = byteOffset; i < arrLength; i++) { | ||
| if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { | ||
| if (foundIndex === -1) { | ||
| foundIndex = i; | ||
| } | ||
| if (i - foundIndex + 1 === valLength) { | ||
| return foundIndex * indexSize; | ||
| } | ||
| } else { | ||
| if (foundIndex !== -1) { | ||
| i -= i - foundIndex; | ||
| } | ||
| foundIndex = -1; | ||
| } | ||
| } | ||
| } else { | ||
| if (byteOffset + valLength > arrLength) { | ||
| byteOffset = arrLength - valLength; | ||
| } | ||
| for (i = byteOffset; i >= 0; i--) { | ||
| let found = true; | ||
| for (let j = 0; j < valLength; j++) { | ||
| if (read(arr, i + j) !== read(val, j)) { | ||
| found = false; | ||
| break; | ||
| } | ||
| } | ||
| if (found) { | ||
| return i; | ||
| } | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
| Buffer.prototype.includes = function includes(val, byteOffset, encoding) { | ||
| return this.indexOf(val, byteOffset, encoding) !== -1; | ||
| }; | ||
| Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { | ||
| return bidirectionalIndexOf(this, val, byteOffset, encoding, true); | ||
| }; | ||
| Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { | ||
| return bidirectionalIndexOf(this, val, byteOffset, encoding, false); | ||
| }; | ||
| function hexWrite(buf, string, offset, length) { | ||
| offset = Number(offset) || 0; | ||
| const remaining = buf.length - offset; | ||
| if (length) { | ||
| length = Number(length); | ||
| if (length > remaining) { | ||
| length = remaining; | ||
| } | ||
| } else { | ||
| length = remaining; | ||
| } | ||
| const strLen = string.length; | ||
| if (length > strLen / 2) { | ||
| length = strLen / 2; | ||
| } | ||
| let i; | ||
| for (i = 0; i < length; ++i) { | ||
| const parsed = Number.parseInt(string.slice(i * 2, i * 2 + 2), 16); | ||
| if (numberIsNaN(parsed)) { | ||
| return i; | ||
| } | ||
| buf[offset + i] = parsed; | ||
| } | ||
| return i; | ||
| } | ||
| function utf8Write(buf, string, offset, length) { | ||
| return blitBuffer( | ||
| utf8ToBytes(string, buf.length - offset), | ||
| buf, | ||
| offset, | ||
| length | ||
| ); | ||
| } | ||
| function asciiWrite(buf, string, offset, length) { | ||
| return blitBuffer(asciiToBytes(string), buf, offset, length); | ||
| } | ||
| function base64Write(buf, string, offset, length) { | ||
| return blitBuffer(base64ToBytes(string), buf, offset, length); | ||
| } | ||
| function ucs2Write(buf, string, offset, length) { | ||
| return blitBuffer( | ||
| utf16leToBytes(string, buf.length - offset), | ||
| buf, | ||
| offset, | ||
| length | ||
| ); | ||
| } | ||
| Buffer.prototype.write = function write(string, offset, length, encoding) { | ||
| if (offset === undefined) { | ||
| encoding = "utf8"; | ||
| length = this.length; | ||
| offset = 0; | ||
| } else if (length === undefined && typeof offset === "string") { | ||
| encoding = offset; | ||
| length = this.length; | ||
| offset = 0; | ||
| } else if (Number.isFinite(offset)) { | ||
| offset = offset >>> 0; | ||
| if (Number.isFinite(length)) { | ||
| length = length >>> 0; | ||
| if (encoding === undefined) { | ||
| encoding = "utf8"; | ||
| } | ||
| } else { | ||
| encoding = length; | ||
| length = undefined; | ||
| } | ||
| } else { | ||
| throw new TypeError( | ||
| "Buffer.write(string, encoding, offset[, length]) is no longer supported" | ||
| ); | ||
| } | ||
| const remaining = this.length - offset; | ||
| if (length === undefined || length > remaining) { | ||
| length = remaining; | ||
| } | ||
| if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { | ||
| throw new RangeError("Attempt to write outside buffer bounds"); | ||
| } | ||
| if (!encoding) { | ||
| encoding = "utf8"; | ||
| } | ||
| let loweredCase = false; | ||
| for (; ; ) { | ||
| switch (encoding) { | ||
| case "hex": { | ||
| return hexWrite(this, string, offset, length); | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8Write(this, string, offset, length); | ||
| } | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": { | ||
| return asciiWrite(this, string, offset, length); | ||
| } | ||
| case "base64": { | ||
| return base64Write(this, string, offset, length); | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return ucs2Write(this, string, offset, length); | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| encoding = ("" + encoding).toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| Buffer.prototype.toJSON = function toJSON() { | ||
| return { | ||
| type: "Buffer", | ||
| data: Array.prototype.slice.call(this._arr || this, 0) | ||
| }; | ||
| }; | ||
| function base64Slice(buf, start, end) { | ||
| return start === 0 && end === buf.length ? fromByteArray(buf) : fromByteArray(buf.slice(start, end)); | ||
| } | ||
| function utf8Slice(buf, start, end) { | ||
| end = Math.min(buf.length, end); | ||
| const res = []; | ||
| let i = start; | ||
| while (i < end) { | ||
| const firstByte = buf[i]; | ||
| let codePoint = null; | ||
| let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; | ||
| if (i + bytesPerSequence <= end) { | ||
| let secondByte, thirdByte, fourthByte, tempCodePoint; | ||
| switch (bytesPerSequence) { | ||
| case 1: { | ||
| if (firstByte < 128) { | ||
| codePoint = firstByte; | ||
| } | ||
| break; | ||
| } | ||
| case 2: { | ||
| secondByte = buf[i + 1]; | ||
| if ((secondByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; | ||
| if (tempCodePoint > 127) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
| case 3: { | ||
| secondByte = buf[i + 1]; | ||
| thirdByte = buf[i + 2]; | ||
| if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; | ||
| if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
| case 4: { | ||
| secondByte = buf[i + 1]; | ||
| thirdByte = buf[i + 2]; | ||
| fourthByte = buf[i + 3]; | ||
| if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; | ||
| if (tempCodePoint > 65535 && tempCodePoint < 1114112) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (codePoint === null) { | ||
| codePoint = 65533; | ||
| bytesPerSequence = 1; | ||
| } else if (codePoint > 65535) { | ||
| codePoint -= 65536; | ||
| res.push(codePoint >>> 10 & 1023 | 55296); | ||
| codePoint = 56320 | codePoint & 1023; | ||
| } | ||
| res.push(codePoint); | ||
| i += bytesPerSequence; | ||
| } | ||
| return decodeCodePointsArray(res); | ||
| } | ||
| const MAX_ARGUMENTS_LENGTH = 4096; | ||
| function decodeCodePointsArray(codePoints) { | ||
| const len = codePoints.length; | ||
| if (len <= MAX_ARGUMENTS_LENGTH) { | ||
| return String.fromCharCode.apply(String, codePoints); | ||
| } | ||
| let res = ""; | ||
| let i = 0; | ||
| while (i < len) { | ||
| res += String.fromCharCode.apply( | ||
| String, | ||
| codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) | ||
| ); | ||
| } | ||
| return res; | ||
| } | ||
| function asciiSlice(buf, start, end) { | ||
| let ret = ""; | ||
| end = Math.min(buf.length, end); | ||
| for (let i = start; i < end; ++i) { | ||
| ret += String.fromCharCode(buf[i] & 127); | ||
| } | ||
| return ret; | ||
| } | ||
| function latin1Slice(buf, start, end) { | ||
| let ret = ""; | ||
| end = Math.min(buf.length, end); | ||
| for (let i = start; i < end; ++i) { | ||
| ret += String.fromCharCode(buf[i]); | ||
| } | ||
| return ret; | ||
| } | ||
| function hexSlice(buf, start, end) { | ||
| const len = buf.length; | ||
| if (!start || start < 0) { | ||
| start = 0; | ||
| } | ||
| if (!end || end < 0 || end > len) { | ||
| end = len; | ||
| } | ||
| let out = ""; | ||
| for (let i = start; i < end; ++i) { | ||
| out += hexSliceLookupTable[buf[i]]; | ||
| } | ||
| return out; | ||
| } | ||
| function utf16leSlice(buf, start, end) { | ||
| const bytes = buf.slice(start, end); | ||
| let res = ""; | ||
| for (let i = 0; i < bytes.length - 1; i += 2) { | ||
| res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); | ||
| } | ||
| return res; | ||
| } | ||
| Buffer.prototype.slice = function slice(start, end) { | ||
| const len = this.length; | ||
| start = Math.trunc(start); | ||
| end = end === undefined ? len : Math.trunc(end); | ||
| if (start < 0) { | ||
| start += len; | ||
| if (start < 0) { | ||
| start = 0; | ||
| } | ||
| } else if (start > len) { | ||
| start = len; | ||
| } | ||
| if (end < 0) { | ||
| end += len; | ||
| if (end < 0) { | ||
| end = 0; | ||
| } | ||
| } else if (end > len) { | ||
| end = len; | ||
| } | ||
| if (end < start) { | ||
| end = start; | ||
| } | ||
| const newBuf = this.subarray(start, end); | ||
| Object.setPrototypeOf(newBuf, Buffer.prototype); | ||
| return newBuf; | ||
| }; | ||
| function checkOffset(offset, ext, length) { | ||
| if (offset % 1 !== 0 || offset < 0) { | ||
| throw new RangeError("offset is not uint"); | ||
| } | ||
| if (offset + ext > length) { | ||
| throw new RangeError("Trying to access beyond buffer length"); | ||
| } | ||
| } | ||
| Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset]; | ||
| let mul = 1; | ||
| let i = 0; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| val += this[offset + i] * mul; | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset + --byteLength2]; | ||
| let mul = 1; | ||
| while (byteLength2 > 0 && (mul *= 256)) { | ||
| val += this[offset + --byteLength2] * mul; | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 1, this.length); | ||
| } | ||
| return this[offset]; | ||
| }; | ||
| Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| return this[offset] | this[offset + 1] << 8; | ||
| }; | ||
| Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| return this[offset] << 8 | this[offset + 1]; | ||
| }; | ||
| Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; | ||
| }; | ||
| Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); | ||
| }; | ||
| Buffer.prototype.readBigUInt64LE = defineBigIntMethod( | ||
| function readBigUInt64LE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24; | ||
| const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; | ||
| return BigInt(lo) + (BigInt(hi) << BigInt(32)); | ||
| } | ||
| ); | ||
| Buffer.prototype.readBigUInt64BE = defineBigIntMethod( | ||
| function readBigUInt64BE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; | ||
| const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; | ||
| return (BigInt(hi) << BigInt(32)) + BigInt(lo); | ||
| } | ||
| ); | ||
| Buffer.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset]; | ||
| let mul = 1; | ||
| let i = 0; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| val += this[offset + i] * mul; | ||
| } | ||
| mul *= 128; | ||
| if (val >= mul) { | ||
| val -= Math.pow(2, 8 * byteLength2); | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let i = byteLength2; | ||
| let mul = 1; | ||
| let val = this[offset + --i]; | ||
| while (i > 0 && (mul *= 256)) { | ||
| val += this[offset + --i] * mul; | ||
| } | ||
| mul *= 128; | ||
| if (val >= mul) { | ||
| val -= Math.pow(2, 8 * byteLength2); | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 1, this.length); | ||
| } | ||
| if (!(this[offset] & 128)) { | ||
| return this[offset]; | ||
| } | ||
| return (255 - this[offset] + 1) * -1; | ||
| }; | ||
| Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| const val = this[offset] | this[offset + 1] << 8; | ||
| return val & 32768 ? val | 4294901760 : val; | ||
| }; | ||
| Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| const val = this[offset + 1] | this[offset] << 8; | ||
| return val & 32768 ? val | 4294901760 : val; | ||
| }; | ||
| Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; | ||
| }; | ||
| Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; | ||
| }; | ||
| Buffer.prototype.readBigInt64LE = defineBigIntMethod( | ||
| function readBigInt64LE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); | ||
| return (BigInt(val) << BigInt(32)) + BigInt( | ||
| first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24 | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.readBigInt64BE = defineBigIntMethod( | ||
| function readBigInt64BE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const val = (first << 24) + // Overflow | ||
| this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; | ||
| return (BigInt(val) << BigInt(32)) + BigInt( | ||
| this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return read(this, offset, true, 23, 4); | ||
| }; | ||
| Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return read(this, offset, false, 23, 4); | ||
| }; | ||
| Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 8, this.length); | ||
| } | ||
| return read(this, offset, true, 52, 8); | ||
| }; | ||
| Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 8, this.length); | ||
| } | ||
| return read(this, offset, false, 52, 8); | ||
| }; | ||
| function checkInt(buf, value, offset, ext, max, min) { | ||
| if (!Buffer.isBuffer(buf)) { | ||
| throw new TypeError('"buffer" argument must be a Buffer instance'); | ||
| } | ||
| if (value > max || value < min) { | ||
| throw new RangeError('"value" argument is out of bounds'); | ||
| } | ||
| if (offset + ext > buf.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| } | ||
| Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| const maxBytes = Math.pow(2, 8 * byteLength2) - 1; | ||
| checkInt(this, value, offset, byteLength2, maxBytes, 0); | ||
| } | ||
| let mul = 1; | ||
| let i = 0; | ||
| this[offset] = value & 255; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| this[offset + i] = value / mul & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| const maxBytes = Math.pow(2, 8 * byteLength2) - 1; | ||
| checkInt(this, value, offset, byteLength2, maxBytes, 0); | ||
| } | ||
| let i = byteLength2 - 1; | ||
| let mul = 1; | ||
| this[offset + i] = value & 255; | ||
| while (--i >= 0 && (mul *= 256)) { | ||
| this[offset + i] = value / mul & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 1, 255, 0); | ||
| } | ||
| this[offset] = value & 255; | ||
| return offset + 1; | ||
| }; | ||
| Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 65535, 0); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 65535, 0); | ||
| } | ||
| this[offset] = value >>> 8; | ||
| this[offset + 1] = value & 255; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 4294967295, 0); | ||
| } | ||
| this[offset + 3] = value >>> 24; | ||
| this[offset + 2] = value >>> 16; | ||
| this[offset + 1] = value >>> 8; | ||
| this[offset] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 4294967295, 0); | ||
| } | ||
| this[offset] = value >>> 24; | ||
| this[offset + 1] = value >>> 16; | ||
| this[offset + 2] = value >>> 8; | ||
| this[offset + 3] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| function wrtBigUInt64LE(buf, value, offset, min, max) { | ||
| checkIntBI(value, min, max, buf, offset, 7); | ||
| let lo = Number(value & BigInt(4294967295)); | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| let hi = Number(value >> BigInt(32) & BigInt(4294967295)); | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| return offset; | ||
| } | ||
| function wrtBigUInt64BE(buf, value, offset, min, max) { | ||
| checkIntBI(value, min, max, buf, offset, 7); | ||
| let lo = Number(value & BigInt(4294967295)); | ||
| buf[offset + 7] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 6] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 5] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 4] = lo; | ||
| let hi = Number(value >> BigInt(32) & BigInt(4294967295)); | ||
| buf[offset + 3] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset + 2] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset + 1] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset] = hi; | ||
| return offset + 8; | ||
| } | ||
| Buffer.prototype.writeBigUInt64LE = defineBigIntMethod( | ||
| function writeBigUInt64LE(value, offset = 0) { | ||
| return wrtBigUInt64LE( | ||
| this, | ||
| value, | ||
| offset, | ||
| BigInt(0), | ||
| BigInt("0xffffffffffffffff") | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.writeBigUInt64BE = defineBigIntMethod( | ||
| function writeBigUInt64BE(value, offset = 0) { | ||
| return wrtBigUInt64BE( | ||
| this, | ||
| value, | ||
| offset, | ||
| BigInt(0), | ||
| BigInt("0xffffffffffffffff") | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| const limit = Math.pow(2, 8 * byteLength2 - 1); | ||
| checkInt(this, value, offset, byteLength2, limit - 1, -limit); | ||
| } | ||
| let i = 0; | ||
| let mul = 1; | ||
| let sub = 0; | ||
| this[offset] = value & 255; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { | ||
| sub = 1; | ||
| } | ||
| this[offset + i] = Math.trunc(value / mul) - sub & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| const limit = Math.pow(2, 8 * byteLength2 - 1); | ||
| checkInt(this, value, offset, byteLength2, limit - 1, -limit); | ||
| } | ||
| let i = byteLength2 - 1; | ||
| let mul = 1; | ||
| let sub = 0; | ||
| this[offset + i] = value & 255; | ||
| while (--i >= 0 && (mul *= 256)) { | ||
| if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { | ||
| sub = 1; | ||
| } | ||
| this[offset + i] = Math.trunc(value / mul) - sub & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 1, 127, -128); | ||
| } | ||
| if (value < 0) { | ||
| value = 255 + value + 1; | ||
| } | ||
| this[offset] = value & 255; | ||
| return offset + 1; | ||
| }; | ||
| Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 32767, -32768); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 32767, -32768); | ||
| } | ||
| this[offset] = value >>> 8; | ||
| this[offset + 1] = value & 255; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 2147483647, -2147483648); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| this[offset + 2] = value >>> 16; | ||
| this[offset + 3] = value >>> 24; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 2147483647, -2147483648); | ||
| } | ||
| if (value < 0) { | ||
| value = 4294967295 + value + 1; | ||
| } | ||
| this[offset] = value >>> 24; | ||
| this[offset + 1] = value >>> 16; | ||
| this[offset + 2] = value >>> 8; | ||
| this[offset + 3] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { | ||
| return wrtBigUInt64LE( | ||
| this, | ||
| value, | ||
| offset, | ||
| -BigInt("0x8000000000000000"), | ||
| BigInt("0x7fffffffffffffff") | ||
| ); | ||
| }); | ||
| Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { | ||
| return wrtBigUInt64BE( | ||
| this, | ||
| value, | ||
| offset, | ||
| -BigInt("0x8000000000000000"), | ||
| BigInt("0x7fffffffffffffff") | ||
| ); | ||
| }); | ||
| function checkIEEE754(buf, value, offset, ext, max, min) { | ||
| if (offset + ext > buf.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| if (offset < 0) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| } | ||
| function writeFloat(buf, value, offset, littleEndian, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkIEEE754( | ||
| buf, | ||
| value, | ||
| offset, | ||
| 4); | ||
| } | ||
| write(buf, value, offset, littleEndian, 23, 4); | ||
| return offset + 4; | ||
| } | ||
| Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { | ||
| return writeFloat(this, value, offset, true, noAssert); | ||
| }; | ||
| Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { | ||
| return writeFloat(this, value, offset, false, noAssert); | ||
| }; | ||
| function writeDouble(buf, value, offset, littleEndian, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkIEEE754( | ||
| buf, | ||
| value, | ||
| offset, | ||
| 8); | ||
| } | ||
| write(buf, value, offset, littleEndian, 52, 8); | ||
| return offset + 8; | ||
| } | ||
| Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { | ||
| return writeDouble(this, value, offset, true, noAssert); | ||
| }; | ||
| Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { | ||
| return writeDouble(this, value, offset, false, noAssert); | ||
| }; | ||
| Buffer.prototype.copy = function copy(target, targetStart, start, end) { | ||
| if (!Buffer.isBuffer(target)) { | ||
| throw new TypeError("argument should be a Buffer"); | ||
| } | ||
| if (!start) { | ||
| start = 0; | ||
| } | ||
| if (!end && end !== 0) { | ||
| end = this.length; | ||
| } | ||
| if (targetStart >= target.length) { | ||
| targetStart = target.length; | ||
| } | ||
| if (!targetStart) { | ||
| targetStart = 0; | ||
| } | ||
| if (end > 0 && end < start) { | ||
| end = start; | ||
| } | ||
| if (end === start) { | ||
| return 0; | ||
| } | ||
| if (target.length === 0 || this.length === 0) { | ||
| return 0; | ||
| } | ||
| if (targetStart < 0) { | ||
| throw new RangeError("targetStart out of bounds"); | ||
| } | ||
| if (start < 0 || start >= this.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| if (end < 0) { | ||
| throw new RangeError("sourceEnd out of bounds"); | ||
| } | ||
| if (end > this.length) { | ||
| end = this.length; | ||
| } | ||
| if (target.length - targetStart < end - start) { | ||
| end = target.length - targetStart + start; | ||
| } | ||
| const len = end - start; | ||
| if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { | ||
| this.copyWithin(targetStart, start, end); | ||
| } else { | ||
| Uint8Array.prototype.set.call( | ||
| target, | ||
| this.subarray(start, end), | ||
| targetStart | ||
| ); | ||
| } | ||
| return len; | ||
| }; | ||
| Buffer.prototype.fill = function fill(val, start, end, encoding) { | ||
| if (typeof val === "string") { | ||
| if (typeof start === "string") { | ||
| encoding = start; | ||
| start = 0; | ||
| end = this.length; | ||
| } else if (typeof end === "string") { | ||
| encoding = end; | ||
| end = this.length; | ||
| } | ||
| if (encoding !== undefined && typeof encoding !== "string") { | ||
| throw new TypeError("encoding must be a string"); | ||
| } | ||
| if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| if (val.length === 1) { | ||
| const code = val.charCodeAt(0); | ||
| if (encoding === "utf8" && code < 128 || encoding === "latin1") { | ||
| val = code; | ||
| } | ||
| } | ||
| } else if (typeof val === "number") { | ||
| val = val & 255; | ||
| } else if (typeof val === "boolean") { | ||
| val = Number(val); | ||
| } | ||
| if (start < 0 || this.length < start || this.length < end) { | ||
| throw new RangeError("Out of range index"); | ||
| } | ||
| if (end <= start) { | ||
| return this; | ||
| } | ||
| start = start >>> 0; | ||
| end = end === undefined ? this.length : end >>> 0; | ||
| if (!val) { | ||
| val = 0; | ||
| } | ||
| let i; | ||
| if (typeof val === "number") { | ||
| for (i = start; i < end; ++i) { | ||
| this[i] = val; | ||
| } | ||
| } else { | ||
| const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); | ||
| const len = bytes.length; | ||
| if (len === 0) { | ||
| throw new TypeError( | ||
| 'The value "' + val + '" is invalid for argument "value"' | ||
| ); | ||
| } | ||
| for (i = 0; i < end - start; ++i) { | ||
| this[i + start] = bytes[i % len]; | ||
| } | ||
| } | ||
| return this; | ||
| }; | ||
| const errors = {}; | ||
| function E(sym, getMessage, Base) { | ||
| errors[sym] = class NodeError extends Base { | ||
| constructor() { | ||
| super(); | ||
| Object.defineProperty(this, "message", { | ||
| value: Reflect.apply(getMessage, this, arguments), | ||
| writable: true, | ||
| configurable: true | ||
| }); | ||
| this.name = `${this.name} [${sym}]`; | ||
| this.stack; | ||
| delete this.name; | ||
| } | ||
| get code() { | ||
| return sym; | ||
| } | ||
| set code(value) { | ||
| Object.defineProperty(this, "code", { | ||
| configurable: true, | ||
| enumerable: true, | ||
| value, | ||
| writable: true | ||
| }); | ||
| } | ||
| toString() { | ||
| return `${this.name} [${sym}]: ${this.message}`; | ||
| } | ||
| }; | ||
| } | ||
| E( | ||
| "ERR_BUFFER_OUT_OF_BOUNDS", | ||
| function(name) { | ||
| if (name) { | ||
| return `${name} is outside of buffer bounds`; | ||
| } | ||
| return "Attempt to access memory outside buffer bounds"; | ||
| }, | ||
| RangeError | ||
| ); | ||
| E( | ||
| "ERR_INVALID_ARG_TYPE", | ||
| function(name, actual) { | ||
| return `The "${name}" argument must be of type number. Received type ${typeof actual}`; | ||
| }, | ||
| TypeError | ||
| ); | ||
| E( | ||
| "ERR_OUT_OF_RANGE", | ||
| function(str, range, input) { | ||
| let msg = `The value of "${str}" is out of range.`; | ||
| let received = input; | ||
| if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { | ||
| received = addNumericalSeparator(String(input)); | ||
| } else if (typeof input === "bigint") { | ||
| received = String(input); | ||
| if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { | ||
| received = addNumericalSeparator(received); | ||
| } | ||
| received += "n"; | ||
| } | ||
| msg += ` It must be ${range}. Received ${received}`; | ||
| return msg; | ||
| }, | ||
| RangeError | ||
| ); | ||
| function addNumericalSeparator(val) { | ||
| let res = ""; | ||
| let i = val.length; | ||
| const start = val[0] === "-" ? 1 : 0; | ||
| for (; i >= start + 4; i -= 3) { | ||
| res = `_${val.slice(i - 3, i)}${res}`; | ||
| } | ||
| return `${val.slice(0, i)}${res}`; | ||
| } | ||
| function checkBounds(buf, offset, byteLength2) { | ||
| validateNumber(offset, "offset"); | ||
| if (buf[offset] === undefined || buf[offset + byteLength2] === undefined) { | ||
| boundsError(offset, buf.length - (byteLength2 + 1)); | ||
| } | ||
| } | ||
| function checkIntBI(value, min, max, buf, offset, byteLength2) { | ||
| if (value > max || value < min) { | ||
| const n = typeof min === "bigint" ? "n" : ""; | ||
| let range; | ||
| { | ||
| range = min === 0 || min === BigInt(0) ? `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}` : `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`; | ||
| } | ||
| throw new errors.ERR_OUT_OF_RANGE("value", range, value); | ||
| } | ||
| checkBounds(buf, offset, byteLength2); | ||
| } | ||
| function validateNumber(value, name) { | ||
| if (typeof value !== "number") { | ||
| throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value); | ||
| } | ||
| } | ||
| function boundsError(value, length, type) { | ||
| if (Math.floor(value) !== value) { | ||
| validateNumber(value, type); | ||
| throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value); | ||
| } | ||
| if (length < 0) { | ||
| throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); | ||
| } | ||
| throw new errors.ERR_OUT_OF_RANGE( | ||
| "offset", | ||
| `>= ${0} and <= ${length}`, | ||
| value | ||
| ); | ||
| } | ||
| const INVALID_BASE64_RE = /[^\w+/-]/g; | ||
| function base64clean(str) { | ||
| str = str.split("=")[0]; | ||
| str = str.trim().replace(INVALID_BASE64_RE, ""); | ||
| if (str.length < 2) { | ||
| return ""; | ||
| } | ||
| while (str.length % 4 !== 0) { | ||
| str = str + "="; | ||
| } | ||
| return str; | ||
| } | ||
| function utf8ToBytes(string, units) { | ||
| units = units || Number.POSITIVE_INFINITY; | ||
| let codePoint; | ||
| const length = string.length; | ||
| let leadSurrogate = null; | ||
| const bytes = []; | ||
| for (let i = 0; i < length; ++i) { | ||
| codePoint = string.charCodeAt(i); | ||
| if (codePoint > 55295 && codePoint < 57344) { | ||
| if (!leadSurrogate) { | ||
| if (codePoint > 56319) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| continue; | ||
| } else if (i + 1 === length) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| continue; | ||
| } | ||
| leadSurrogate = codePoint; | ||
| continue; | ||
| } | ||
| if (codePoint < 56320) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| leadSurrogate = codePoint; | ||
| continue; | ||
| } | ||
| codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; | ||
| } else if (leadSurrogate && // valid bmp char, but last char was a lead | ||
| (units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| leadSurrogate = null; | ||
| if (codePoint < 128) { | ||
| if ((units -= 1) < 0) { | ||
| break; | ||
| } | ||
| bytes.push(codePoint); | ||
| } else if (codePoint < 2048) { | ||
| if ((units -= 2) < 0) { | ||
| break; | ||
| } | ||
| bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128); | ||
| } else if (codePoint < 65536) { | ||
| if ((units -= 3) < 0) { | ||
| break; | ||
| } | ||
| bytes.push( | ||
| codePoint >> 12 | 224, | ||
| codePoint >> 6 & 63 | 128, | ||
| codePoint & 63 | 128 | ||
| ); | ||
| } else if (codePoint < 1114112) { | ||
| if ((units -= 4) < 0) { | ||
| break; | ||
| } | ||
| bytes.push( | ||
| codePoint >> 18 | 240, | ||
| codePoint >> 12 & 63 | 128, | ||
| codePoint >> 6 & 63 | 128, | ||
| codePoint & 63 | 128 | ||
| ); | ||
| } else { | ||
| throw new Error("Invalid code point"); | ||
| } | ||
| } | ||
| return bytes; | ||
| } | ||
| function asciiToBytes(str) { | ||
| const byteArray = []; | ||
| for (let i = 0; i < str.length; ++i) { | ||
| byteArray.push(str.charCodeAt(i) & 255); | ||
| } | ||
| return byteArray; | ||
| } | ||
| function utf16leToBytes(str, units) { | ||
| let c, hi, lo; | ||
| const byteArray = []; | ||
| for (let i = 0; i < str.length; ++i) { | ||
| if ((units -= 2) < 0) { | ||
| break; | ||
| } | ||
| c = str.charCodeAt(i); | ||
| hi = c >> 8; | ||
| lo = c % 256; | ||
| byteArray.push(lo, hi); | ||
| } | ||
| return byteArray; | ||
| } | ||
| function base64ToBytes(str) { | ||
| return toByteArray(base64clean(str)); | ||
| } | ||
| function blitBuffer(src, dst, offset, length) { | ||
| let i; | ||
| for (i = 0; i < length; ++i) { | ||
| if (i + offset >= dst.length || i >= src.length) { | ||
| break; | ||
| } | ||
| dst[i + offset] = src[i]; | ||
| } | ||
| return i; | ||
| } | ||
| function isInstance(obj, type) { | ||
| return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; | ||
| } | ||
| function numberIsNaN(obj) { | ||
| return obj !== obj; | ||
| } | ||
| const hexSliceLookupTable = function() { | ||
| const alphabet = "0123456789abcdef"; | ||
| const table = Array.from({ length: 256 }); | ||
| for (let i = 0; i < 16; ++i) { | ||
| const i16 = i * 16; | ||
| for (let j = 0; j < 16; ++j) { | ||
| table[i16 + j] = alphabet[i] + alphabet[j]; | ||
| } | ||
| } | ||
| return table; | ||
| }(); | ||
| function defineBigIntMethod(fn) { | ||
| return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; | ||
| } | ||
| function BufferBigIntNotDefined() { | ||
| throw new Error("BigInt not supported"); | ||
| } | ||
| exports.Buffer = Buffer; |
@@ -1,1 +0,2035 @@ | ||
| const w=[],y=[],rt=typeof Uint8Array>"u"?Array:Uint8Array,N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=N.length;t<e;++t)w[t]=N[t],y[N.charCodeAt(t)]=t;y[45]=62,y[95]=63;function ot(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");n===-1&&(n=e);const r=n===e?0:4-n%4;return[n,r]}function ft(t,e,n){return(e+n)*3/4-n}function it(t){let e;const n=ot(t),r=n[0],o=n[1],f=new rt(ft(t,r,o));let u=0;const h=o>0?r-4:r;let c;for(c=0;c<h;c+=4)e=y[t.charCodeAt(c)]<<18|y[t.charCodeAt(c+1)]<<12|y[t.charCodeAt(c+2)]<<6|y[t.charCodeAt(c+3)],f[u++]=e>>16&255,f[u++]=e>>8&255,f[u++]=e&255;return o===2&&(e=y[t.charCodeAt(c)]<<2|y[t.charCodeAt(c+1)]>>4,f[u++]=e&255),o===1&&(e=y[t.charCodeAt(c)]<<10|y[t.charCodeAt(c+1)]<<4|y[t.charCodeAt(c+2)]>>2,f[u++]=e>>8&255,f[u++]=e&255),f}function ut(t){return w[t>>18&63]+w[t>>12&63]+w[t>>6&63]+w[t&63]}function st(t,e,n){let r;const o=[];for(let f=e;f<n;f+=3)r=(t[f]<<16&16711680)+(t[f+1]<<8&65280)+(t[f+2]&255),o.push(ut(r));return o.join("")}function P(t){let e;const n=t.length,r=n%3,o=[],f=16383;for(let u=0,h=n-r;u<h;u+=f)o.push(st(t,u,u+f>h?h:u+f));return r===1?(e=t[n-1],o.push(w[e>>2]+w[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(w[e>>10]+w[e>>4&63]+w[e<<2&63]+"=")),o.join("")}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function T(t,e,n,r,o){let f,u;const h=o*8-r-1,c=(1<<h)-1,l=c>>1;let s=-7,a=n?o-1:0;const I=n?-1:1;let d=t[e+a];for(a+=I,f=d&(1<<-s)-1,d>>=-s,s+=h;s>0;)f=f*256+t[e+a],a+=I,s-=8;for(u=f&(1<<-s)-1,f>>=-s,s+=r;s>0;)u=u*256+t[e+a],a+=I,s-=8;if(f===0)f=1-l;else{if(f===c)return u?Number.NaN:(d?-1:1)*Number.POSITIVE_INFINITY;u=u+Math.pow(2,r),f=f-l}return(d?-1:1)*u*Math.pow(2,f-r)}function F(t,e,n,r,o,f){let u,h,c,l=f*8-o-1;const s=(1<<l)-1,a=s>>1,I=o===23?Math.pow(2,-24)-Math.pow(2,-77):0;let d=r?0:f-1;const L=r?1:-1,nt=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),Number.isNaN(e)||e===Number.POSITIVE_INFINITY?(h=Number.isNaN(e)?1:0,u=s):(u=Math.floor(Math.log2(e)),e*(c=Math.pow(2,-u))<1&&(u--,c*=2),e+=u+a>=1?I/c:I*Math.pow(2,1-a),e*c>=2&&(u++,c/=2),u+a>=s?(h=0,u=s):u+a>=1?(h=(e*c-1)*Math.pow(2,o),u=u+a):(h=e*Math.pow(2,a-1)*Math.pow(2,o),u=0));o>=8;)t[n+d]=h&255,d+=L,h/=256,o-=8;for(u=u<<o|h,l+=o;l>0;)t[n+d]=u&255,d+=L,u/=256,l-=8;t[n+d-L]|=nt*128}const k=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null,ht=50,S=2147483647;i.TYPED_ARRAY_SUPPORT=ct(),!i.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This environment lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ct(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}});function m(t){if(t>S)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(t)}return j(t,e,n)}i.poolSize=8192;function j(t,e,n){if(typeof t=="string")return lt(t,e);if(ArrayBuffer.isView(t))return pt(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(b(t,ArrayBuffer)||t&&b(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(b(t,SharedArrayBuffer)||t&&b(t.buffer,SharedArrayBuffer)))return Y(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return i.from(r,e,n);const o=gt(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}i.from=function(t,e,n){return j(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array);function D(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function at(t,e,n){return D(t),t<=0?m(t):e!==void 0?typeof n=="string"?m(t).fill(e,n):m(t).fill(e):m(t)}i.alloc=function(t,e,n){return at(t,e,n)};function _(t){return D(t),m(t<0?0:x(t)|0)}i.allocUnsafe=function(t){return _(t)},i.allocUnsafeSlow=function(t){return _(t)};function lt(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=z(t,e)|0;let r=m(n);const o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function v(t){const e=t.length<0?0:x(t.length)|0,n=m(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function pt(t){if(b(t,Uint8Array)){const e=new Uint8Array(t);return Y(e.buffer,e.byteOffset,e.byteLength)}return v(t)}function Y(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function gt(t){if(i.isBuffer(t)){const e=x(t.length)|0,n=m(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||M(t.length)?m(0):v(t);if(t.type==="Buffer"&&Array.isArray(t.data))return v(t.data)}function x(t){if(t>=S)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+S.toString(16)+" bytes");return t|0}i.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==i.prototype},i.compare=function(t,e){if(b(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),b(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let o=0,f=Math.min(n,r);o<f;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return i.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=i.allocUnsafe(e);let o=0;for(n=0;n<t.length;++n){let f=t[n];if(b(f,Uint8Array))o+f.length>r.length?(i.isBuffer(f)||(f=i.from(f.buffer,f.byteOffset,f.byteLength)),f.copy(r,o)):Uint8Array.prototype.set.call(r,f,o);else if(i.isBuffer(f))f.copy(r,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=f.length}return r};function z(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||b(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return et(t).length;default:{if(o)return r?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}}i.byteLength=z;function yt(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Rt(this,e,n);case"utf8":case"utf-8":return q(this,e,n);case"ascii":return At(this,e,n);case"latin1":case"binary":return Ut(this,e,n);case"base64":return Bt(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tt(this,e,n);default:{if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}}i.prototype._isBuffer=!0;function B(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}i.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)B(this,e,e+1);return this},i.prototype.swap32=function(){const t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)B(this,e,e+3),B(this,e+1,e+2);return this},i.prototype.swap64=function(){const t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)B(this,e,e+7),B(this,e+1,e+6),B(this,e+2,e+5),B(this,e+3,e+4);return this},i.prototype.toString=function(){const t=this.length;return t===0?"":arguments.length===0?q(this,0,t):Reflect.apply(yt,this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:i.compare(this,t)===0},i.prototype.inspect=function(){let t="";const e=ht;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},k&&(i.prototype[k]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(b(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),r===void 0&&(r=0),o===void 0&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,o>>>=0,this===t)return 0;let f=o-r,u=n-e;const h=Math.min(f,u),c=this.slice(r,o),l=t.slice(e,n);for(let s=0;s<h;++s)if(c[s]!==l[s]){f=c[s],u=l[s];break}return f<u?-1:u<f?1:0};function V(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,M(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=i.from(e,r)),i.isBuffer(e))return e.length===0?-1:G(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):G(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function G(t,e,n,r,o){let f=1,u=t.length,h=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;f=2,u/=2,h/=2,n/=2}function c(s,a){return f===1?s[a]:s.readUInt16BE(a*f)}let l;if(o){let s=-1;for(l=n;l<u;l++)if(c(t,l)===c(e,s===-1?0:l-s)){if(s===-1&&(s=l),l-s+1===h)return s*f}else s!==-1&&(l-=l-s),s=-1}else for(n+h>u&&(n=u-h),l=n;l>=0;l--){let s=!0;for(let a=0;a<h;a++)if(c(t,l+a)!==c(e,a)){s=!1;break}if(s)return l}return-1}i.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},i.prototype.indexOf=function(t,e,n){return V(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return V(this,t,e,n,!1)};function dt(t,e,n,r){n=Number(n)||0;const o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;const f=e.length;r>f/2&&(r=f/2);let u;for(u=0;u<r;++u){const h=Number.parseInt(e.slice(u*2,u*2+2),16);if(M(h))return u;t[n+u]=h}return u}function wt(t,e,n,r){return O($(e,t.length-n),t,n,r)}function bt(t,e,n,r){return O(St(e),t,n,r)}function mt(t,e,n,r){return O(et(e),t,n,r)}function Et(t,e,n,r){return O(_t(e,t.length-n),t,n,r)}i.prototype.write=function(t,e,n,r){if(e===void 0)r="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")r=e,n=this.length,e=0;else if(Number.isFinite(e))e=e>>>0,Number.isFinite(n)?(n=n>>>0,r===void 0&&(r="utf8")):(r=n,n=void 0);else throw new TypeError("Buffer.write(string, encoding, offset[, length]) is no longer supported");const o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let f=!1;for(;;)switch(r){case"hex":return dt(this,t,e,n);case"utf8":case"utf-8":return wt(this,t,e,n);case"ascii":case"latin1":case"binary":return bt(this,t,e,n);case"base64":return mt(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,t,e,n);default:{if(f)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),f=!0}}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Bt(t,e,n){return e===0&&n===t.length?P(t):P(t.slice(e,n))}function q(t,e,n){n=Math.min(t.length,n);const r=[];let o=e;for(;o<n;){const f=t[o];let u=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=n){let c,l,s,a;switch(h){case 1:{f<128&&(u=f);break}case 2:{c=t[o+1],(c&192)===128&&(a=(f&31)<<6|c&63,a>127&&(u=a));break}case 3:{c=t[o+1],l=t[o+2],(c&192)===128&&(l&192)===128&&(a=(f&15)<<12|(c&63)<<6|l&63,a>2047&&(a<55296||a>57343)&&(u=a));break}case 4:c=t[o+1],l=t[o+2],s=t[o+3],(c&192)===128&&(l&192)===128&&(s&192)===128&&(a=(f&15)<<18|(c&63)<<12|(l&63)<<6|s&63,a>65535&&a<1114112&&(u=a))}}u===null?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|u&1023),r.push(u),o+=h}return It(r)}const W=4096;function It(t){const e=t.length;if(e<=W)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=W));return n}function At(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function Ut(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Rt(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let f=e;f<n;++f)o+=vt[t[f]];return o}function Tt(t,e,n){const r=t.slice(e,n);let o="";for(let f=0;f<r.length-1;f+=2)o+=String.fromCharCode(r[f]+r[f+1]*256);return o}i.prototype.slice=function(t,e){const n=this.length;t=Math.trunc(t),e=e===void 0?n:Math.trunc(e),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r};function p(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||p(t,e,this.length);let r=this[t],o=1,f=0;for(;++f<e&&(o*=256);)r+=this[t+f]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||p(t,e,this.length);let r=this[t+--e],o=1;for(;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t=t>>>0,e||p(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||p(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||p(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||p(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||p(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=E(function(t){t=t>>>0,U(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&R(t,this.length-8);const r=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(r)+(BigInt(o)<<BigInt(32))}),i.prototype.readBigUInt64BE=E(function(t){t=t>>>0,U(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&R(t,this.length-8);const r=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(o)}),i.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||p(t,e,this.length);let r=this[t],o=1,f=0;for(;++f<e&&(o*=256);)r+=this[t+f]*o;return o*=128,r>=o&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||p(t,e,this.length);let r=e,o=1,f=this[t+--r];for(;r>0&&(o*=256);)f+=this[t+--r]*o;return o*=128,f>=o&&(f-=Math.pow(2,8*e)),f},i.prototype.readInt8=function(t,e){return t=t>>>0,e||p(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},i.prototype.readInt16LE=function(t,e){t=t>>>0,e||p(t,2,this.length);const n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},i.prototype.readInt16BE=function(t,e){t=t>>>0,e||p(t,2,this.length);const n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},i.prototype.readInt32LE=function(t,e){return t=t>>>0,e||p(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t=t>>>0,e||p(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=E(function(t){t=t>>>0,U(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&R(t,this.length-8);const r=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),i.prototype.readBigInt64BE=E(function(t){t=t>>>0,U(t,"offset");const e=this[t],n=this[t+7];(e===void 0||n===void 0)&&R(t,this.length-8);const r=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)}),i.prototype.readFloatLE=function(t,e){return t=t>>>0,e||p(t,4,this.length),T(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t=t>>>0,e||p(t,4,this.length),T(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||p(t,8,this.length),T(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||p(t,8,this.length),T(this,t,!1,52,8)};function g(t,e,n,r,o,f){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<f)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e=e>>>0,n=n>>>0,!r){const u=Math.pow(2,8*n)-1;g(this,t,e,n,u,0)}let o=1,f=0;for(this[e]=t&255;++f<n&&(o*=256);)this[e+f]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e=e>>>0,n=n>>>0,!r){const u=Math.pow(2,8*n)-1;g(this,t,e,n,u,0)}let o=n-1,f=1;for(this[e+o]=t&255;--o>=0&&(f*=256);)this[e+o]=t/f&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,1,255,0),this[e]=t&255,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function J(t,e,n,r,o){tt(e,r,o,t,n,7);let f=Number(e&BigInt(4294967295));t[n++]=f,f=f>>8,t[n++]=f,f=f>>8,t[n++]=f,f=f>>8,t[n++]=f;let u=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=u,u=u>>8,t[n++]=u,u=u>>8,t[n++]=u,u=u>>8,t[n++]=u,n}function X(t,e,n,r,o){tt(e,r,o,t,n,7);let f=Number(e&BigInt(4294967295));t[n+7]=f,f=f>>8,t[n+6]=f,f=f>>8,t[n+5]=f,f=f>>8,t[n+4]=f;let u=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=u,u=u>>8,t[n+2]=u,u=u>>8,t[n+1]=u,u=u>>8,t[n]=u,n+8}i.prototype.writeBigUInt64LE=E(function(t,e=0){return J(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=E(function(t,e=0){return X(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e=e>>>0,!r){const h=Math.pow(2,8*n-1);g(this,t,e,n,h-1,-h)}let o=0,f=1,u=0;for(this[e]=t&255;++o<n&&(f*=256);)t<0&&u===0&&this[e+o-1]!==0&&(u=1),this[e+o]=Math.trunc(t/f)-u&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e=e>>>0,!r){const h=Math.pow(2,8*n-1);g(this,t,e,n,h-1,-h)}let o=n-1,f=1,u=0;for(this[e+o]=t&255;--o>=0&&(f*=256);)t<0&&u===0&&this[e+o+1]!==0&&(u=1),this[e+o]=Math.trunc(t/f)-u&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||g(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},i.prototype.writeBigInt64LE=E(function(t,e=0){return J(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=E(function(t,e=0){return X(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function H(t,e,n,r,o,f){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function K(t,e,n,r,o){return e=+e,n=n>>>0,o||H(t,e,n,4),F(t,e,n,r,23,4),n+4}i.prototype.writeFloatLE=function(t,e,n){return K(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return K(this,t,e,!1,n)};function Q(t,e,n,r,o){return e=+e,n=n>>>0,o||H(t,e,n,8),F(t,e,n,r,52,8),n+8}i.prototype.writeDoubleLE=function(t,e,n){return Q(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return Q(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!r&&r!==0&&(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const o=r-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if(typeof t=="string"){if(typeof e=="string"?(r=e,e=0,n=this.length):typeof n=="string"&&(r=n,n=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(t.length===1){const f=t.charCodeAt(0);(r==="utf8"&&f<128||r==="latin1")&&(t=f)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<n;++o)this[o]=t;else{const f=i.isBuffer(t)?t:i.from(t,r),u=f.length;if(u===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-e;++o)this[o+e]=f[o%u]}return this};const A={};function C(t,e,n){A[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:Reflect.apply(e,this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(r){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:r,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}C("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),C("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),C("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=Z(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=Z(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function Z(t){let e="",n=t.length;const r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Ot(t,e,n){U(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&R(e,t.length-(n+1))}function tt(t,e,n,r,o,f){if(t>n||t<e){const u=typeof e=="bigint"?"n":"";let h;throw h=e===0||e===BigInt(0)?`>= 0${u} and < 2${u} ** ${(f+1)*8}${u}`:`>= -(2${u} ** ${(f+1)*8-1}${u}) and < 2 ** ${(f+1)*8-1}${u}`,new A.ERR_OUT_OF_RANGE("value",h,t)}Ot(r,o,f)}function U(t,e){if(typeof t!="number")throw new A.ERR_INVALID_ARG_TYPE(e,"number",t)}function R(t,e,n){throw Math.floor(t)!==t?(U(t,n),new A.ERR_OUT_OF_RANGE("offset","an integer",t)):e<0?new A.ERR_BUFFER_OUT_OF_BOUNDS:new A.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}const Lt=/[^\w+/-]/g;function Nt(t){if(t=t.split("=")[0],t=t.trim().replace(Lt,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function $(t,e){e=e||Number.POSITIVE_INFINITY;let n;const r=t.length;let o=null;const f=[];for(let u=0;u<r;++u){if(n=t.charCodeAt(u),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&f.push(239,191,189);continue}else if(u+1===r){(e-=3)>-1&&f.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&f.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&f.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;f.push(n)}else if(n<2048){if((e-=2)<0)break;f.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;f.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;f.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return f}function St(t){const e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function _t(t,e){let n,r,o;const f=[];for(let u=0;u<t.length&&!((e-=2)<0);++u)n=t.charCodeAt(u),r=n>>8,o=n%256,f.push(o,r);return f}function et(t){return it(Nt(t))}function O(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function b(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function M(t){return t!==t}const vt=function(){const t="0123456789abcdef",e=Array.from({length:256});for(let n=0;n<16;++n){const r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e}();function E(t){return typeof BigInt>"u"?xt:t}function xt(){throw new Error("BigInt not supported")}export{i as Buffer}; | ||
| const lookup = []; | ||
| const revLookup = []; | ||
| const Arr = typeof Uint8Array === "undefined" ? Array : Uint8Array; | ||
| const code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| for (let i = 0, len = code.length; i < len; ++i) { | ||
| lookup[i] = code[i]; | ||
| revLookup[code.charCodeAt(i)] = i; | ||
| } | ||
| revLookup["-".charCodeAt(0)] = 62; | ||
| revLookup["_".charCodeAt(0)] = 63; | ||
| function getLens(b64) { | ||
| const len = b64.length; | ||
| if (len % 4 > 0) { | ||
| throw new Error("Invalid string. Length must be a multiple of 4"); | ||
| } | ||
| let validLen = b64.indexOf("="); | ||
| if (validLen === -1) { | ||
| validLen = len; | ||
| } | ||
| const placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; | ||
| return [validLen, placeHoldersLen]; | ||
| } | ||
| function _byteLength(b64, validLen, placeHoldersLen) { | ||
| return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; | ||
| } | ||
| function toByteArray(b64) { | ||
| let tmp; | ||
| const lens = getLens(b64); | ||
| const validLen = lens[0]; | ||
| const placeHoldersLen = lens[1]; | ||
| const arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); | ||
| let curByte = 0; | ||
| const len = placeHoldersLen > 0 ? validLen - 4 : validLen; | ||
| let i; | ||
| for (i = 0; i < len; i += 4) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; | ||
| arr[curByte++] = tmp >> 16 & 255; | ||
| arr[curByte++] = tmp >> 8 & 255; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| if (placeHoldersLen === 2) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| if (placeHoldersLen === 1) { | ||
| tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; | ||
| arr[curByte++] = tmp >> 8 & 255; | ||
| arr[curByte++] = tmp & 255; | ||
| } | ||
| return arr; | ||
| } | ||
| function tripletToBase64(num) { | ||
| return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; | ||
| } | ||
| function encodeChunk(uint8, start, end) { | ||
| let tmp; | ||
| const output = []; | ||
| for (let i = start; i < end; i += 3) { | ||
| tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255); | ||
| output.push(tripletToBase64(tmp)); | ||
| } | ||
| return output.join(""); | ||
| } | ||
| function fromByteArray(uint8) { | ||
| let tmp; | ||
| const len = uint8.length; | ||
| const extraBytes = len % 3; | ||
| const parts = []; | ||
| const maxChunkLength = 16383; | ||
| for (let i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { | ||
| parts.push( | ||
| encodeChunk( | ||
| uint8, | ||
| i, | ||
| i + maxChunkLength > len2 ? len2 : i + maxChunkLength | ||
| ) | ||
| ); | ||
| } | ||
| if (extraBytes === 1) { | ||
| tmp = uint8[len - 1]; | ||
| parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="); | ||
| } else if (extraBytes === 2) { | ||
| tmp = (uint8[len - 2] << 8) + uint8[len - 1]; | ||
| parts.push( | ||
| lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=" | ||
| ); | ||
| } | ||
| return parts.join(""); | ||
| } | ||
| /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
| function read(buffer, offset, isLE, mLen, nBytes) { | ||
| let e, m; | ||
| const eLen = nBytes * 8 - mLen - 1; | ||
| const eMax = (1 << eLen) - 1; | ||
| const eBias = eMax >> 1; | ||
| let nBits = -7; | ||
| let i = isLE ? nBytes - 1 : 0; | ||
| const d = isLE ? -1 : 1; | ||
| let s = buffer[offset + i]; | ||
| i += d; | ||
| e = s & (1 << -nBits) - 1; | ||
| s >>= -nBits; | ||
| nBits += eLen; | ||
| while (nBits > 0) { | ||
| e = e * 256 + buffer[offset + i]; | ||
| i += d; | ||
| nBits -= 8; | ||
| } | ||
| m = e & (1 << -nBits) - 1; | ||
| e >>= -nBits; | ||
| nBits += mLen; | ||
| while (nBits > 0) { | ||
| m = m * 256 + buffer[offset + i]; | ||
| i += d; | ||
| nBits -= 8; | ||
| } | ||
| if (e === 0) { | ||
| e = 1 - eBias; | ||
| } else if (e === eMax) { | ||
| return m ? Number.NaN : (s ? -1 : 1) * Number.POSITIVE_INFINITY; | ||
| } else { | ||
| m = m + Math.pow(2, mLen); | ||
| e = e - eBias; | ||
| } | ||
| return (s ? -1 : 1) * m * Math.pow(2, e - mLen); | ||
| } | ||
| function write(buffer, value, offset, isLE, mLen, nBytes) { | ||
| let e, m, c; | ||
| let eLen = nBytes * 8 - mLen - 1; | ||
| const eMax = (1 << eLen) - 1; | ||
| const eBias = eMax >> 1; | ||
| const rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; | ||
| let i = isLE ? 0 : nBytes - 1; | ||
| const d = isLE ? 1 : -1; | ||
| const s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; | ||
| value = Math.abs(value); | ||
| if (Number.isNaN(value) || value === Number.POSITIVE_INFINITY) { | ||
| m = Number.isNaN(value) ? 1 : 0; | ||
| e = eMax; | ||
| } else { | ||
| e = Math.floor(Math.log2(value)); | ||
| if (value * (c = Math.pow(2, -e)) < 1) { | ||
| e--; | ||
| c *= 2; | ||
| } | ||
| value += e + eBias >= 1 ? rt / c : rt * Math.pow(2, 1 - eBias); | ||
| if (value * c >= 2) { | ||
| e++; | ||
| c /= 2; | ||
| } | ||
| if (e + eBias >= eMax) { | ||
| m = 0; | ||
| e = eMax; | ||
| } else if (e + eBias >= 1) { | ||
| m = (value * c - 1) * Math.pow(2, mLen); | ||
| e = e + eBias; | ||
| } else { | ||
| m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); | ||
| e = 0; | ||
| } | ||
| } | ||
| while (mLen >= 8) { | ||
| buffer[offset + i] = m & 255; | ||
| i += d; | ||
| m /= 256; | ||
| mLen -= 8; | ||
| } | ||
| e = e << mLen | m; | ||
| eLen += mLen; | ||
| while (eLen > 0) { | ||
| buffer[offset + i] = e & 255; | ||
| i += d; | ||
| e /= 256; | ||
| eLen -= 8; | ||
| } | ||
| buffer[offset + i - d] |= s * 128; | ||
| } | ||
| /*! | ||
| * The buffer module from node.js, for the browser. | ||
| * | ||
| * @author Feross Aboukhadijeh <https://feross.org> | ||
| * @license MIT | ||
| */ | ||
| const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; | ||
| const INSPECT_MAX_BYTES = 50; | ||
| const K_MAX_LENGTH = 2147483647; | ||
| Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); | ||
| if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") { | ||
| console.error( | ||
| "This environment lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support." | ||
| ); | ||
| } | ||
| function typedArraySupport() { | ||
| try { | ||
| const arr = new Uint8Array(1); | ||
| const proto = { | ||
| foo: function() { | ||
| return 42; | ||
| } | ||
| }; | ||
| Object.setPrototypeOf(proto, Uint8Array.prototype); | ||
| Object.setPrototypeOf(arr, proto); | ||
| return arr.foo() === 42; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| Object.defineProperty(Buffer.prototype, "parent", { | ||
| enumerable: true, | ||
| get: function() { | ||
| if (!Buffer.isBuffer(this)) { | ||
| return; | ||
| } | ||
| return this.buffer; | ||
| } | ||
| }); | ||
| Object.defineProperty(Buffer.prototype, "offset", { | ||
| enumerable: true, | ||
| get: function() { | ||
| if (!Buffer.isBuffer(this)) { | ||
| return; | ||
| } | ||
| return this.byteOffset; | ||
| } | ||
| }); | ||
| function createBuffer(length) { | ||
| if (length > K_MAX_LENGTH) { | ||
| throw new RangeError( | ||
| 'The value "' + length + '" is invalid for option "size"' | ||
| ); | ||
| } | ||
| const buf = new Uint8Array(length); | ||
| Object.setPrototypeOf(buf, Buffer.prototype); | ||
| return buf; | ||
| } | ||
| function Buffer(arg, encodingOrOffset, length) { | ||
| if (typeof arg === "number") { | ||
| if (typeof encodingOrOffset === "string") { | ||
| throw new TypeError( | ||
| 'The "string" argument must be of type string. Received type number' | ||
| ); | ||
| } | ||
| return allocUnsafe(arg); | ||
| } | ||
| return from(arg, encodingOrOffset, length); | ||
| } | ||
| Buffer.poolSize = 8192; | ||
| function from(value, encodingOrOffset, length) { | ||
| if (typeof value === "string") { | ||
| return fromString(value, encodingOrOffset); | ||
| } | ||
| if (ArrayBuffer.isView(value)) { | ||
| return fromArrayView(value); | ||
| } | ||
| if (value == null) { | ||
| throw new TypeError( | ||
| "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value | ||
| ); | ||
| } | ||
| if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { | ||
| return fromArrayBuffer(value, encodingOrOffset, length); | ||
| } | ||
| if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) { | ||
| return fromArrayBuffer(value, encodingOrOffset, length); | ||
| } | ||
| if (typeof value === "number") { | ||
| throw new TypeError( | ||
| 'The "value" argument must not be of type number. Received type number' | ||
| ); | ||
| } | ||
| const valueOf = value.valueOf && value.valueOf(); | ||
| if (valueOf != null && valueOf !== value) { | ||
| return Buffer.from(valueOf, encodingOrOffset, length); | ||
| } | ||
| const b = fromObject(value); | ||
| if (b) { | ||
| return b; | ||
| } | ||
| if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") { | ||
| return Buffer.from( | ||
| value[Symbol.toPrimitive]("string"), | ||
| encodingOrOffset, | ||
| length | ||
| ); | ||
| } | ||
| throw new TypeError( | ||
| "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value | ||
| ); | ||
| } | ||
| Buffer.from = function(value, encodingOrOffset, length) { | ||
| return from(value, encodingOrOffset, length); | ||
| }; | ||
| Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); | ||
| Object.setPrototypeOf(Buffer, Uint8Array); | ||
| function assertSize(size) { | ||
| if (typeof size !== "number") { | ||
| throw new TypeError('"size" argument must be of type number'); | ||
| } else if (size < 0) { | ||
| throw new RangeError( | ||
| 'The value "' + size + '" is invalid for option "size"' | ||
| ); | ||
| } | ||
| } | ||
| function alloc(size, fill2, encoding) { | ||
| assertSize(size); | ||
| if (size <= 0) { | ||
| return createBuffer(size); | ||
| } | ||
| if (fill2 !== undefined) { | ||
| return typeof encoding === "string" ? createBuffer(size).fill(fill2, encoding) : createBuffer(size).fill(fill2); | ||
| } | ||
| return createBuffer(size); | ||
| } | ||
| Buffer.alloc = function(size, fill2, encoding) { | ||
| return alloc(size, fill2, encoding); | ||
| }; | ||
| function allocUnsafe(size) { | ||
| assertSize(size); | ||
| return createBuffer(size < 0 ? 0 : checked(size) | 0); | ||
| } | ||
| Buffer.allocUnsafe = function(size) { | ||
| return allocUnsafe(size); | ||
| }; | ||
| Buffer.allocUnsafeSlow = function(size) { | ||
| return allocUnsafe(size); | ||
| }; | ||
| function fromString(string, encoding) { | ||
| if (typeof encoding !== "string" || encoding === "") { | ||
| encoding = "utf8"; | ||
| } | ||
| if (!Buffer.isEncoding(encoding)) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| const length = byteLength(string, encoding) | 0; | ||
| let buf = createBuffer(length); | ||
| const actual = buf.write(string, encoding); | ||
| if (actual !== length) { | ||
| buf = buf.slice(0, actual); | ||
| } | ||
| return buf; | ||
| } | ||
| function fromArrayLike(array) { | ||
| const length = array.length < 0 ? 0 : checked(array.length) | 0; | ||
| const buf = createBuffer(length); | ||
| for (let i = 0; i < length; i += 1) { | ||
| buf[i] = array[i] & 255; | ||
| } | ||
| return buf; | ||
| } | ||
| function fromArrayView(arrayView) { | ||
| if (isInstance(arrayView, Uint8Array)) { | ||
| const copy2 = new Uint8Array(arrayView); | ||
| return fromArrayBuffer(copy2.buffer, copy2.byteOffset, copy2.byteLength); | ||
| } | ||
| return fromArrayLike(arrayView); | ||
| } | ||
| function fromArrayBuffer(array, byteOffset, length) { | ||
| if (byteOffset < 0 || array.byteLength < byteOffset) { | ||
| throw new RangeError('"offset" is outside of buffer bounds'); | ||
| } | ||
| if (array.byteLength < byteOffset + (length || 0)) { | ||
| throw new RangeError('"length" is outside of buffer bounds'); | ||
| } | ||
| let buf; | ||
| if (byteOffset === undefined && length === undefined) { | ||
| buf = new Uint8Array(array); | ||
| } else if (length === undefined) { | ||
| buf = new Uint8Array(array, byteOffset); | ||
| } else { | ||
| buf = new Uint8Array(array, byteOffset, length); | ||
| } | ||
| Object.setPrototypeOf(buf, Buffer.prototype); | ||
| return buf; | ||
| } | ||
| function fromObject(obj) { | ||
| if (Buffer.isBuffer(obj)) { | ||
| const len = checked(obj.length) | 0; | ||
| const buf = createBuffer(len); | ||
| if (buf.length === 0) { | ||
| return buf; | ||
| } | ||
| obj.copy(buf, 0, 0, len); | ||
| return buf; | ||
| } | ||
| if (obj.length !== undefined) { | ||
| if (typeof obj.length !== "number" || numberIsNaN(obj.length)) { | ||
| return createBuffer(0); | ||
| } | ||
| return fromArrayLike(obj); | ||
| } | ||
| if (obj.type === "Buffer" && Array.isArray(obj.data)) { | ||
| return fromArrayLike(obj.data); | ||
| } | ||
| } | ||
| function checked(length) { | ||
| if (length >= K_MAX_LENGTH) { | ||
| throw new RangeError( | ||
| "Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes" | ||
| ); | ||
| } | ||
| return length | 0; | ||
| } | ||
| Buffer.isBuffer = function isBuffer(b) { | ||
| return b != null && b._isBuffer === true && b !== Buffer.prototype; | ||
| }; | ||
| Buffer.compare = function compare(a, b) { | ||
| if (isInstance(a, Uint8Array)) { | ||
| a = Buffer.from(a, a.offset, a.byteLength); | ||
| } | ||
| if (isInstance(b, Uint8Array)) { | ||
| b = Buffer.from(b, b.offset, b.byteLength); | ||
| } | ||
| if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { | ||
| throw new TypeError( | ||
| 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array' | ||
| ); | ||
| } | ||
| if (a === b) { | ||
| return 0; | ||
| } | ||
| let x = a.length; | ||
| let y = b.length; | ||
| for (let i = 0, len = Math.min(x, y); i < len; ++i) { | ||
| if (a[i] !== b[i]) { | ||
| x = a[i]; | ||
| y = b[i]; | ||
| break; | ||
| } | ||
| } | ||
| if (x < y) { | ||
| return -1; | ||
| } | ||
| if (y < x) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| Buffer.isEncoding = function isEncoding(encoding) { | ||
| switch (String(encoding).toLowerCase()) { | ||
| case "hex": | ||
| case "utf8": | ||
| case "utf-8": | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": | ||
| case "base64": | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return true; | ||
| } | ||
| default: { | ||
| return false; | ||
| } | ||
| } | ||
| }; | ||
| Buffer.concat = function concat(list, length) { | ||
| if (!Array.isArray(list)) { | ||
| throw new TypeError('"list" argument must be an Array of Buffers'); | ||
| } | ||
| if (list.length === 0) { | ||
| return Buffer.alloc(0); | ||
| } | ||
| let i; | ||
| if (length === undefined) { | ||
| length = 0; | ||
| for (i = 0; i < list.length; ++i) { | ||
| length += list[i].length; | ||
| } | ||
| } | ||
| const buffer = Buffer.allocUnsafe(length); | ||
| let pos = 0; | ||
| for (i = 0; i < list.length; ++i) { | ||
| let buf = list[i]; | ||
| if (isInstance(buf, Uint8Array)) { | ||
| if (pos + buf.length > buffer.length) { | ||
| if (!Buffer.isBuffer(buf)) { | ||
| buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength); | ||
| } | ||
| buf.copy(buffer, pos); | ||
| } else { | ||
| Uint8Array.prototype.set.call(buffer, buf, pos); | ||
| } | ||
| } else if (Buffer.isBuffer(buf)) { | ||
| buf.copy(buffer, pos); | ||
| } else { | ||
| throw new TypeError('"list" argument must be an Array of Buffers'); | ||
| } | ||
| pos += buf.length; | ||
| } | ||
| return buffer; | ||
| }; | ||
| function byteLength(string, encoding) { | ||
| if (Buffer.isBuffer(string)) { | ||
| return string.length; | ||
| } | ||
| if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) { | ||
| return string.byteLength; | ||
| } | ||
| if (typeof string !== "string") { | ||
| throw new TypeError( | ||
| 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string | ||
| ); | ||
| } | ||
| const len = string.length; | ||
| const mustMatch = arguments.length > 2 && arguments[2] === true; | ||
| if (!mustMatch && len === 0) { | ||
| return 0; | ||
| } | ||
| let loweredCase = false; | ||
| for (; ; ) { | ||
| switch (encoding) { | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": { | ||
| return len; | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8ToBytes(string).length; | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return len * 2; | ||
| } | ||
| case "hex": { | ||
| return len >>> 1; | ||
| } | ||
| case "base64": { | ||
| return base64ToBytes(string).length; | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| return mustMatch ? -1 : utf8ToBytes(string).length; | ||
| } | ||
| encoding = ("" + encoding).toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Buffer.byteLength = byteLength; | ||
| function slowToString(encoding, start, end) { | ||
| let loweredCase = false; | ||
| if (start === undefined || start < 0) { | ||
| start = 0; | ||
| } | ||
| if (start > this.length) { | ||
| return ""; | ||
| } | ||
| if (end === undefined || end > this.length) { | ||
| end = this.length; | ||
| } | ||
| if (end <= 0) { | ||
| return ""; | ||
| } | ||
| end >>>= 0; | ||
| start >>>= 0; | ||
| if (end <= start) { | ||
| return ""; | ||
| } | ||
| if (!encoding) { | ||
| encoding = "utf8"; | ||
| } | ||
| while (true) { | ||
| switch (encoding) { | ||
| case "hex": { | ||
| return hexSlice(this, start, end); | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8Slice(this, start, end); | ||
| } | ||
| case "ascii": { | ||
| return asciiSlice(this, start, end); | ||
| } | ||
| case "latin1": | ||
| case "binary": { | ||
| return latin1Slice(this, start, end); | ||
| } | ||
| case "base64": { | ||
| return base64Slice(this, start, end); | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return utf16leSlice(this, start, end); | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| encoding = (encoding + "").toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Buffer.prototype._isBuffer = true; | ||
| function swap(b, n, m) { | ||
| const i = b[n]; | ||
| b[n] = b[m]; | ||
| b[m] = i; | ||
| } | ||
| Buffer.prototype.swap16 = function swap16() { | ||
| const len = this.length; | ||
| if (len % 2 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 16-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 2) { | ||
| swap(this, i, i + 1); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.swap32 = function swap32() { | ||
| const len = this.length; | ||
| if (len % 4 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 32-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 4) { | ||
| swap(this, i, i + 3); | ||
| swap(this, i + 1, i + 2); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.swap64 = function swap64() { | ||
| const len = this.length; | ||
| if (len % 8 !== 0) { | ||
| throw new RangeError("Buffer size must be a multiple of 64-bits"); | ||
| } | ||
| for (let i = 0; i < len; i += 8) { | ||
| swap(this, i, i + 7); | ||
| swap(this, i + 1, i + 6); | ||
| swap(this, i + 2, i + 5); | ||
| swap(this, i + 3, i + 4); | ||
| } | ||
| return this; | ||
| }; | ||
| Buffer.prototype.toString = function toString() { | ||
| const length = this.length; | ||
| if (length === 0) { | ||
| return ""; | ||
| } | ||
| if (arguments.length === 0) { | ||
| return utf8Slice(this, 0, length); | ||
| } | ||
| return Reflect.apply(slowToString, this, arguments); | ||
| }; | ||
| Buffer.prototype.toLocaleString = Buffer.prototype.toString; | ||
| Buffer.prototype.equals = function equals(b) { | ||
| if (!Buffer.isBuffer(b)) { | ||
| throw new TypeError("Argument must be a Buffer"); | ||
| } | ||
| if (this === b) { | ||
| return true; | ||
| } | ||
| return Buffer.compare(this, b) === 0; | ||
| }; | ||
| Buffer.prototype.inspect = function inspect() { | ||
| let str = ""; | ||
| const max = INSPECT_MAX_BYTES; | ||
| str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); | ||
| if (this.length > max) { | ||
| str += " ... "; | ||
| } | ||
| return "<Buffer " + str + ">"; | ||
| }; | ||
| if (customInspectSymbol) { | ||
| Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; | ||
| } | ||
| Buffer.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) { | ||
| if (isInstance(target, Uint8Array)) { | ||
| target = Buffer.from(target, target.offset, target.byteLength); | ||
| } | ||
| if (!Buffer.isBuffer(target)) { | ||
| throw new TypeError( | ||
| 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target | ||
| ); | ||
| } | ||
| if (start === undefined) { | ||
| start = 0; | ||
| } | ||
| if (end === undefined) { | ||
| end = target ? target.length : 0; | ||
| } | ||
| if (thisStart === undefined) { | ||
| thisStart = 0; | ||
| } | ||
| if (thisEnd === undefined) { | ||
| thisEnd = this.length; | ||
| } | ||
| if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { | ||
| throw new RangeError("out of range index"); | ||
| } | ||
| if (thisStart >= thisEnd && start >= end) { | ||
| return 0; | ||
| } | ||
| if (thisStart >= thisEnd) { | ||
| return -1; | ||
| } | ||
| if (start >= end) { | ||
| return 1; | ||
| } | ||
| start >>>= 0; | ||
| end >>>= 0; | ||
| thisStart >>>= 0; | ||
| thisEnd >>>= 0; | ||
| if (this === target) { | ||
| return 0; | ||
| } | ||
| let x = thisEnd - thisStart; | ||
| let y = end - start; | ||
| const len = Math.min(x, y); | ||
| const thisCopy = this.slice(thisStart, thisEnd); | ||
| const targetCopy = target.slice(start, end); | ||
| for (let i = 0; i < len; ++i) { | ||
| if (thisCopy[i] !== targetCopy[i]) { | ||
| x = thisCopy[i]; | ||
| y = targetCopy[i]; | ||
| break; | ||
| } | ||
| } | ||
| if (x < y) { | ||
| return -1; | ||
| } | ||
| if (y < x) { | ||
| return 1; | ||
| } | ||
| return 0; | ||
| }; | ||
| function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { | ||
| if (buffer.length === 0) { | ||
| return -1; | ||
| } | ||
| if (typeof byteOffset === "string") { | ||
| encoding = byteOffset; | ||
| byteOffset = 0; | ||
| } else if (byteOffset > 2147483647) { | ||
| byteOffset = 2147483647; | ||
| } else if (byteOffset < -2147483648) { | ||
| byteOffset = -2147483648; | ||
| } | ||
| byteOffset = +byteOffset; | ||
| if (numberIsNaN(byteOffset)) { | ||
| byteOffset = dir ? 0 : buffer.length - 1; | ||
| } | ||
| if (byteOffset < 0) { | ||
| byteOffset = buffer.length + byteOffset; | ||
| } | ||
| if (byteOffset >= buffer.length) { | ||
| if (dir) { | ||
| return -1; | ||
| } else { | ||
| byteOffset = buffer.length - 1; | ||
| } | ||
| } else if (byteOffset < 0) { | ||
| if (dir) { | ||
| byteOffset = 0; | ||
| } else { | ||
| return -1; | ||
| } | ||
| } | ||
| if (typeof val === "string") { | ||
| val = Buffer.from(val, encoding); | ||
| } | ||
| if (Buffer.isBuffer(val)) { | ||
| if (val.length === 0) { | ||
| return -1; | ||
| } | ||
| return arrayIndexOf(buffer, val, byteOffset, encoding, dir); | ||
| } else if (typeof val === "number") { | ||
| val = val & 255; | ||
| if (typeof Uint8Array.prototype.indexOf === "function") { | ||
| return dir ? Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) : Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); | ||
| } | ||
| return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); | ||
| } | ||
| throw new TypeError("val must be string, number or Buffer"); | ||
| } | ||
| function arrayIndexOf(arr, val, byteOffset, encoding, dir) { | ||
| let indexSize = 1; | ||
| let arrLength = arr.length; | ||
| let valLength = val.length; | ||
| if (encoding !== undefined) { | ||
| encoding = String(encoding).toLowerCase(); | ||
| if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { | ||
| if (arr.length < 2 || val.length < 2) { | ||
| return -1; | ||
| } | ||
| indexSize = 2; | ||
| arrLength /= 2; | ||
| valLength /= 2; | ||
| byteOffset /= 2; | ||
| } | ||
| } | ||
| function read(buf, i2) { | ||
| return indexSize === 1 ? buf[i2] : buf.readUInt16BE(i2 * indexSize); | ||
| } | ||
| let i; | ||
| if (dir) { | ||
| let foundIndex = -1; | ||
| for (i = byteOffset; i < arrLength; i++) { | ||
| if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { | ||
| if (foundIndex === -1) { | ||
| foundIndex = i; | ||
| } | ||
| if (i - foundIndex + 1 === valLength) { | ||
| return foundIndex * indexSize; | ||
| } | ||
| } else { | ||
| if (foundIndex !== -1) { | ||
| i -= i - foundIndex; | ||
| } | ||
| foundIndex = -1; | ||
| } | ||
| } | ||
| } else { | ||
| if (byteOffset + valLength > arrLength) { | ||
| byteOffset = arrLength - valLength; | ||
| } | ||
| for (i = byteOffset; i >= 0; i--) { | ||
| let found = true; | ||
| for (let j = 0; j < valLength; j++) { | ||
| if (read(arr, i + j) !== read(val, j)) { | ||
| found = false; | ||
| break; | ||
| } | ||
| } | ||
| if (found) { | ||
| return i; | ||
| } | ||
| } | ||
| } | ||
| return -1; | ||
| } | ||
| Buffer.prototype.includes = function includes(val, byteOffset, encoding) { | ||
| return this.indexOf(val, byteOffset, encoding) !== -1; | ||
| }; | ||
| Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { | ||
| return bidirectionalIndexOf(this, val, byteOffset, encoding, true); | ||
| }; | ||
| Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { | ||
| return bidirectionalIndexOf(this, val, byteOffset, encoding, false); | ||
| }; | ||
| function hexWrite(buf, string, offset, length) { | ||
| offset = Number(offset) || 0; | ||
| const remaining = buf.length - offset; | ||
| if (length) { | ||
| length = Number(length); | ||
| if (length > remaining) { | ||
| length = remaining; | ||
| } | ||
| } else { | ||
| length = remaining; | ||
| } | ||
| const strLen = string.length; | ||
| if (length > strLen / 2) { | ||
| length = strLen / 2; | ||
| } | ||
| let i; | ||
| for (i = 0; i < length; ++i) { | ||
| const parsed = Number.parseInt(string.slice(i * 2, i * 2 + 2), 16); | ||
| if (numberIsNaN(parsed)) { | ||
| return i; | ||
| } | ||
| buf[offset + i] = parsed; | ||
| } | ||
| return i; | ||
| } | ||
| function utf8Write(buf, string, offset, length) { | ||
| return blitBuffer( | ||
| utf8ToBytes(string, buf.length - offset), | ||
| buf, | ||
| offset, | ||
| length | ||
| ); | ||
| } | ||
| function asciiWrite(buf, string, offset, length) { | ||
| return blitBuffer(asciiToBytes(string), buf, offset, length); | ||
| } | ||
| function base64Write(buf, string, offset, length) { | ||
| return blitBuffer(base64ToBytes(string), buf, offset, length); | ||
| } | ||
| function ucs2Write(buf, string, offset, length) { | ||
| return blitBuffer( | ||
| utf16leToBytes(string, buf.length - offset), | ||
| buf, | ||
| offset, | ||
| length | ||
| ); | ||
| } | ||
| Buffer.prototype.write = function write(string, offset, length, encoding) { | ||
| if (offset === undefined) { | ||
| encoding = "utf8"; | ||
| length = this.length; | ||
| offset = 0; | ||
| } else if (length === undefined && typeof offset === "string") { | ||
| encoding = offset; | ||
| length = this.length; | ||
| offset = 0; | ||
| } else if (Number.isFinite(offset)) { | ||
| offset = offset >>> 0; | ||
| if (Number.isFinite(length)) { | ||
| length = length >>> 0; | ||
| if (encoding === undefined) { | ||
| encoding = "utf8"; | ||
| } | ||
| } else { | ||
| encoding = length; | ||
| length = undefined; | ||
| } | ||
| } else { | ||
| throw new TypeError( | ||
| "Buffer.write(string, encoding, offset[, length]) is no longer supported" | ||
| ); | ||
| } | ||
| const remaining = this.length - offset; | ||
| if (length === undefined || length > remaining) { | ||
| length = remaining; | ||
| } | ||
| if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) { | ||
| throw new RangeError("Attempt to write outside buffer bounds"); | ||
| } | ||
| if (!encoding) { | ||
| encoding = "utf8"; | ||
| } | ||
| let loweredCase = false; | ||
| for (; ; ) { | ||
| switch (encoding) { | ||
| case "hex": { | ||
| return hexWrite(this, string, offset, length); | ||
| } | ||
| case "utf8": | ||
| case "utf-8": { | ||
| return utf8Write(this, string, offset, length); | ||
| } | ||
| case "ascii": | ||
| case "latin1": | ||
| case "binary": { | ||
| return asciiWrite(this, string, offset, length); | ||
| } | ||
| case "base64": { | ||
| return base64Write(this, string, offset, length); | ||
| } | ||
| case "ucs2": | ||
| case "ucs-2": | ||
| case "utf16le": | ||
| case "utf-16le": { | ||
| return ucs2Write(this, string, offset, length); | ||
| } | ||
| default: { | ||
| if (loweredCase) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| encoding = ("" + encoding).toLowerCase(); | ||
| loweredCase = true; | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| Buffer.prototype.toJSON = function toJSON() { | ||
| return { | ||
| type: "Buffer", | ||
| data: Array.prototype.slice.call(this._arr || this, 0) | ||
| }; | ||
| }; | ||
| function base64Slice(buf, start, end) { | ||
| return start === 0 && end === buf.length ? fromByteArray(buf) : fromByteArray(buf.slice(start, end)); | ||
| } | ||
| function utf8Slice(buf, start, end) { | ||
| end = Math.min(buf.length, end); | ||
| const res = []; | ||
| let i = start; | ||
| while (i < end) { | ||
| const firstByte = buf[i]; | ||
| let codePoint = null; | ||
| let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; | ||
| if (i + bytesPerSequence <= end) { | ||
| let secondByte, thirdByte, fourthByte, tempCodePoint; | ||
| switch (bytesPerSequence) { | ||
| case 1: { | ||
| if (firstByte < 128) { | ||
| codePoint = firstByte; | ||
| } | ||
| break; | ||
| } | ||
| case 2: { | ||
| secondByte = buf[i + 1]; | ||
| if ((secondByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; | ||
| if (tempCodePoint > 127) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
| case 3: { | ||
| secondByte = buf[i + 1]; | ||
| thirdByte = buf[i + 2]; | ||
| if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; | ||
| if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| break; | ||
| } | ||
| case 4: { | ||
| secondByte = buf[i + 1]; | ||
| thirdByte = buf[i + 2]; | ||
| fourthByte = buf[i + 3]; | ||
| if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { | ||
| tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; | ||
| if (tempCodePoint > 65535 && tempCodePoint < 1114112) { | ||
| codePoint = tempCodePoint; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (codePoint === null) { | ||
| codePoint = 65533; | ||
| bytesPerSequence = 1; | ||
| } else if (codePoint > 65535) { | ||
| codePoint -= 65536; | ||
| res.push(codePoint >>> 10 & 1023 | 55296); | ||
| codePoint = 56320 | codePoint & 1023; | ||
| } | ||
| res.push(codePoint); | ||
| i += bytesPerSequence; | ||
| } | ||
| return decodeCodePointsArray(res); | ||
| } | ||
| const MAX_ARGUMENTS_LENGTH = 4096; | ||
| function decodeCodePointsArray(codePoints) { | ||
| const len = codePoints.length; | ||
| if (len <= MAX_ARGUMENTS_LENGTH) { | ||
| return String.fromCharCode.apply(String, codePoints); | ||
| } | ||
| let res = ""; | ||
| let i = 0; | ||
| while (i < len) { | ||
| res += String.fromCharCode.apply( | ||
| String, | ||
| codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) | ||
| ); | ||
| } | ||
| return res; | ||
| } | ||
| function asciiSlice(buf, start, end) { | ||
| let ret = ""; | ||
| end = Math.min(buf.length, end); | ||
| for (let i = start; i < end; ++i) { | ||
| ret += String.fromCharCode(buf[i] & 127); | ||
| } | ||
| return ret; | ||
| } | ||
| function latin1Slice(buf, start, end) { | ||
| let ret = ""; | ||
| end = Math.min(buf.length, end); | ||
| for (let i = start; i < end; ++i) { | ||
| ret += String.fromCharCode(buf[i]); | ||
| } | ||
| return ret; | ||
| } | ||
| function hexSlice(buf, start, end) { | ||
| const len = buf.length; | ||
| if (!start || start < 0) { | ||
| start = 0; | ||
| } | ||
| if (!end || end < 0 || end > len) { | ||
| end = len; | ||
| } | ||
| let out = ""; | ||
| for (let i = start; i < end; ++i) { | ||
| out += hexSliceLookupTable[buf[i]]; | ||
| } | ||
| return out; | ||
| } | ||
| function utf16leSlice(buf, start, end) { | ||
| const bytes = buf.slice(start, end); | ||
| let res = ""; | ||
| for (let i = 0; i < bytes.length - 1; i += 2) { | ||
| res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); | ||
| } | ||
| return res; | ||
| } | ||
| Buffer.prototype.slice = function slice(start, end) { | ||
| const len = this.length; | ||
| start = Math.trunc(start); | ||
| end = end === undefined ? len : Math.trunc(end); | ||
| if (start < 0) { | ||
| start += len; | ||
| if (start < 0) { | ||
| start = 0; | ||
| } | ||
| } else if (start > len) { | ||
| start = len; | ||
| } | ||
| if (end < 0) { | ||
| end += len; | ||
| if (end < 0) { | ||
| end = 0; | ||
| } | ||
| } else if (end > len) { | ||
| end = len; | ||
| } | ||
| if (end < start) { | ||
| end = start; | ||
| } | ||
| const newBuf = this.subarray(start, end); | ||
| Object.setPrototypeOf(newBuf, Buffer.prototype); | ||
| return newBuf; | ||
| }; | ||
| function checkOffset(offset, ext, length) { | ||
| if (offset % 1 !== 0 || offset < 0) { | ||
| throw new RangeError("offset is not uint"); | ||
| } | ||
| if (offset + ext > length) { | ||
| throw new RangeError("Trying to access beyond buffer length"); | ||
| } | ||
| } | ||
| Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset]; | ||
| let mul = 1; | ||
| let i = 0; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| val += this[offset + i] * mul; | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset + --byteLength2]; | ||
| let mul = 1; | ||
| while (byteLength2 > 0 && (mul *= 256)) { | ||
| val += this[offset + --byteLength2] * mul; | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 1, this.length); | ||
| } | ||
| return this[offset]; | ||
| }; | ||
| Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| return this[offset] | this[offset + 1] << 8; | ||
| }; | ||
| Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| return this[offset] << 8 | this[offset + 1]; | ||
| }; | ||
| Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; | ||
| }; | ||
| Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); | ||
| }; | ||
| Buffer.prototype.readBigUInt64LE = defineBigIntMethod( | ||
| function readBigUInt64LE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24; | ||
| const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; | ||
| return BigInt(lo) + (BigInt(hi) << BigInt(32)); | ||
| } | ||
| ); | ||
| Buffer.prototype.readBigUInt64BE = defineBigIntMethod( | ||
| function readBigUInt64BE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; | ||
| const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; | ||
| return (BigInt(hi) << BigInt(32)) + BigInt(lo); | ||
| } | ||
| ); | ||
| Buffer.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let val = this[offset]; | ||
| let mul = 1; | ||
| let i = 0; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| val += this[offset + i] * mul; | ||
| } | ||
| mul *= 128; | ||
| if (val >= mul) { | ||
| val -= Math.pow(2, 8 * byteLength2); | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) { | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, byteLength2, this.length); | ||
| } | ||
| let i = byteLength2; | ||
| let mul = 1; | ||
| let val = this[offset + --i]; | ||
| while (i > 0 && (mul *= 256)) { | ||
| val += this[offset + --i] * mul; | ||
| } | ||
| mul *= 128; | ||
| if (val >= mul) { | ||
| val -= Math.pow(2, 8 * byteLength2); | ||
| } | ||
| return val; | ||
| }; | ||
| Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 1, this.length); | ||
| } | ||
| if (!(this[offset] & 128)) { | ||
| return this[offset]; | ||
| } | ||
| return (255 - this[offset] + 1) * -1; | ||
| }; | ||
| Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| const val = this[offset] | this[offset + 1] << 8; | ||
| return val & 32768 ? val | 4294901760 : val; | ||
| }; | ||
| Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 2, this.length); | ||
| } | ||
| const val = this[offset + 1] | this[offset] << 8; | ||
| return val & 32768 ? val | 4294901760 : val; | ||
| }; | ||
| Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; | ||
| }; | ||
| Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; | ||
| }; | ||
| Buffer.prototype.readBigInt64LE = defineBigIntMethod( | ||
| function readBigInt64LE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); | ||
| return (BigInt(val) << BigInt(32)) + BigInt( | ||
| first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24 | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.readBigInt64BE = defineBigIntMethod( | ||
| function readBigInt64BE(offset) { | ||
| offset = offset >>> 0; | ||
| validateNumber(offset, "offset"); | ||
| const first = this[offset]; | ||
| const last = this[offset + 7]; | ||
| if (first === undefined || last === undefined) { | ||
| boundsError(offset, this.length - 8); | ||
| } | ||
| const val = (first << 24) + // Overflow | ||
| this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; | ||
| return (BigInt(val) << BigInt(32)) + BigInt( | ||
| this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return read(this, offset, true, 23, 4); | ||
| }; | ||
| Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 4, this.length); | ||
| } | ||
| return read(this, offset, false, 23, 4); | ||
| }; | ||
| Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 8, this.length); | ||
| } | ||
| return read(this, offset, true, 52, 8); | ||
| }; | ||
| Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkOffset(offset, 8, this.length); | ||
| } | ||
| return read(this, offset, false, 52, 8); | ||
| }; | ||
| function checkInt(buf, value, offset, ext, max, min) { | ||
| if (!Buffer.isBuffer(buf)) { | ||
| throw new TypeError('"buffer" argument must be a Buffer instance'); | ||
| } | ||
| if (value > max || value < min) { | ||
| throw new RangeError('"value" argument is out of bounds'); | ||
| } | ||
| if (offset + ext > buf.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| } | ||
| Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| const maxBytes = Math.pow(2, 8 * byteLength2) - 1; | ||
| checkInt(this, value, offset, byteLength2, maxBytes, 0); | ||
| } | ||
| let mul = 1; | ||
| let i = 0; | ||
| this[offset] = value & 255; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| this[offset + i] = value / mul & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| byteLength2 = byteLength2 >>> 0; | ||
| if (!noAssert) { | ||
| const maxBytes = Math.pow(2, 8 * byteLength2) - 1; | ||
| checkInt(this, value, offset, byteLength2, maxBytes, 0); | ||
| } | ||
| let i = byteLength2 - 1; | ||
| let mul = 1; | ||
| this[offset + i] = value & 255; | ||
| while (--i >= 0 && (mul *= 256)) { | ||
| this[offset + i] = value / mul & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 1, 255, 0); | ||
| } | ||
| this[offset] = value & 255; | ||
| return offset + 1; | ||
| }; | ||
| Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 65535, 0); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 65535, 0); | ||
| } | ||
| this[offset] = value >>> 8; | ||
| this[offset + 1] = value & 255; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 4294967295, 0); | ||
| } | ||
| this[offset + 3] = value >>> 24; | ||
| this[offset + 2] = value >>> 16; | ||
| this[offset + 1] = value >>> 8; | ||
| this[offset] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 4294967295, 0); | ||
| } | ||
| this[offset] = value >>> 24; | ||
| this[offset + 1] = value >>> 16; | ||
| this[offset + 2] = value >>> 8; | ||
| this[offset + 3] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| function wrtBigUInt64LE(buf, value, offset, min, max) { | ||
| checkIntBI(value, min, max, buf, offset, 7); | ||
| let lo = Number(value & BigInt(4294967295)); | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset++] = lo; | ||
| let hi = Number(value >> BigInt(32) & BigInt(4294967295)); | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset++] = hi; | ||
| return offset; | ||
| } | ||
| function wrtBigUInt64BE(buf, value, offset, min, max) { | ||
| checkIntBI(value, min, max, buf, offset, 7); | ||
| let lo = Number(value & BigInt(4294967295)); | ||
| buf[offset + 7] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 6] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 5] = lo; | ||
| lo = lo >> 8; | ||
| buf[offset + 4] = lo; | ||
| let hi = Number(value >> BigInt(32) & BigInt(4294967295)); | ||
| buf[offset + 3] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset + 2] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset + 1] = hi; | ||
| hi = hi >> 8; | ||
| buf[offset] = hi; | ||
| return offset + 8; | ||
| } | ||
| Buffer.prototype.writeBigUInt64LE = defineBigIntMethod( | ||
| function writeBigUInt64LE(value, offset = 0) { | ||
| return wrtBigUInt64LE( | ||
| this, | ||
| value, | ||
| offset, | ||
| BigInt(0), | ||
| BigInt("0xffffffffffffffff") | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.writeBigUInt64BE = defineBigIntMethod( | ||
| function writeBigUInt64BE(value, offset = 0) { | ||
| return wrtBigUInt64BE( | ||
| this, | ||
| value, | ||
| offset, | ||
| BigInt(0), | ||
| BigInt("0xffffffffffffffff") | ||
| ); | ||
| } | ||
| ); | ||
| Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| const limit = Math.pow(2, 8 * byteLength2 - 1); | ||
| checkInt(this, value, offset, byteLength2, limit - 1, -limit); | ||
| } | ||
| let i = 0; | ||
| let mul = 1; | ||
| let sub = 0; | ||
| this[offset] = value & 255; | ||
| while (++i < byteLength2 && (mul *= 256)) { | ||
| if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { | ||
| sub = 1; | ||
| } | ||
| this[offset + i] = Math.trunc(value / mul) - sub & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| const limit = Math.pow(2, 8 * byteLength2 - 1); | ||
| checkInt(this, value, offset, byteLength2, limit - 1, -limit); | ||
| } | ||
| let i = byteLength2 - 1; | ||
| let mul = 1; | ||
| let sub = 0; | ||
| this[offset + i] = value & 255; | ||
| while (--i >= 0 && (mul *= 256)) { | ||
| if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { | ||
| sub = 1; | ||
| } | ||
| this[offset + i] = Math.trunc(value / mul) - sub & 255; | ||
| } | ||
| return offset + byteLength2; | ||
| }; | ||
| Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 1, 127, -128); | ||
| } | ||
| if (value < 0) { | ||
| value = 255 + value + 1; | ||
| } | ||
| this[offset] = value & 255; | ||
| return offset + 1; | ||
| }; | ||
| Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 32767, -32768); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 2, 32767, -32768); | ||
| } | ||
| this[offset] = value >>> 8; | ||
| this[offset + 1] = value & 255; | ||
| return offset + 2; | ||
| }; | ||
| Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 2147483647, -2147483648); | ||
| } | ||
| this[offset] = value & 255; | ||
| this[offset + 1] = value >>> 8; | ||
| this[offset + 2] = value >>> 16; | ||
| this[offset + 3] = value >>> 24; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkInt(this, value, offset, 4, 2147483647, -2147483648); | ||
| } | ||
| if (value < 0) { | ||
| value = 4294967295 + value + 1; | ||
| } | ||
| this[offset] = value >>> 24; | ||
| this[offset + 1] = value >>> 16; | ||
| this[offset + 2] = value >>> 8; | ||
| this[offset + 3] = value & 255; | ||
| return offset + 4; | ||
| }; | ||
| Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { | ||
| return wrtBigUInt64LE( | ||
| this, | ||
| value, | ||
| offset, | ||
| -BigInt("0x8000000000000000"), | ||
| BigInt("0x7fffffffffffffff") | ||
| ); | ||
| }); | ||
| Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { | ||
| return wrtBigUInt64BE( | ||
| this, | ||
| value, | ||
| offset, | ||
| -BigInt("0x8000000000000000"), | ||
| BigInt("0x7fffffffffffffff") | ||
| ); | ||
| }); | ||
| function checkIEEE754(buf, value, offset, ext, max, min) { | ||
| if (offset + ext > buf.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| if (offset < 0) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| } | ||
| function writeFloat(buf, value, offset, littleEndian, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkIEEE754( | ||
| buf, | ||
| value, | ||
| offset, | ||
| 4); | ||
| } | ||
| write(buf, value, offset, littleEndian, 23, 4); | ||
| return offset + 4; | ||
| } | ||
| Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { | ||
| return writeFloat(this, value, offset, true, noAssert); | ||
| }; | ||
| Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { | ||
| return writeFloat(this, value, offset, false, noAssert); | ||
| }; | ||
| function writeDouble(buf, value, offset, littleEndian, noAssert) { | ||
| value = +value; | ||
| offset = offset >>> 0; | ||
| if (!noAssert) { | ||
| checkIEEE754( | ||
| buf, | ||
| value, | ||
| offset, | ||
| 8); | ||
| } | ||
| write(buf, value, offset, littleEndian, 52, 8); | ||
| return offset + 8; | ||
| } | ||
| Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { | ||
| return writeDouble(this, value, offset, true, noAssert); | ||
| }; | ||
| Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { | ||
| return writeDouble(this, value, offset, false, noAssert); | ||
| }; | ||
| Buffer.prototype.copy = function copy(target, targetStart, start, end) { | ||
| if (!Buffer.isBuffer(target)) { | ||
| throw new TypeError("argument should be a Buffer"); | ||
| } | ||
| if (!start) { | ||
| start = 0; | ||
| } | ||
| if (!end && end !== 0) { | ||
| end = this.length; | ||
| } | ||
| if (targetStart >= target.length) { | ||
| targetStart = target.length; | ||
| } | ||
| if (!targetStart) { | ||
| targetStart = 0; | ||
| } | ||
| if (end > 0 && end < start) { | ||
| end = start; | ||
| } | ||
| if (end === start) { | ||
| return 0; | ||
| } | ||
| if (target.length === 0 || this.length === 0) { | ||
| return 0; | ||
| } | ||
| if (targetStart < 0) { | ||
| throw new RangeError("targetStart out of bounds"); | ||
| } | ||
| if (start < 0 || start >= this.length) { | ||
| throw new RangeError("Index out of range"); | ||
| } | ||
| if (end < 0) { | ||
| throw new RangeError("sourceEnd out of bounds"); | ||
| } | ||
| if (end > this.length) { | ||
| end = this.length; | ||
| } | ||
| if (target.length - targetStart < end - start) { | ||
| end = target.length - targetStart + start; | ||
| } | ||
| const len = end - start; | ||
| if (this === target && typeof Uint8Array.prototype.copyWithin === "function") { | ||
| this.copyWithin(targetStart, start, end); | ||
| } else { | ||
| Uint8Array.prototype.set.call( | ||
| target, | ||
| this.subarray(start, end), | ||
| targetStart | ||
| ); | ||
| } | ||
| return len; | ||
| }; | ||
| Buffer.prototype.fill = function fill(val, start, end, encoding) { | ||
| if (typeof val === "string") { | ||
| if (typeof start === "string") { | ||
| encoding = start; | ||
| start = 0; | ||
| end = this.length; | ||
| } else if (typeof end === "string") { | ||
| encoding = end; | ||
| end = this.length; | ||
| } | ||
| if (encoding !== undefined && typeof encoding !== "string") { | ||
| throw new TypeError("encoding must be a string"); | ||
| } | ||
| if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) { | ||
| throw new TypeError("Unknown encoding: " + encoding); | ||
| } | ||
| if (val.length === 1) { | ||
| const code = val.charCodeAt(0); | ||
| if (encoding === "utf8" && code < 128 || encoding === "latin1") { | ||
| val = code; | ||
| } | ||
| } | ||
| } else if (typeof val === "number") { | ||
| val = val & 255; | ||
| } else if (typeof val === "boolean") { | ||
| val = Number(val); | ||
| } | ||
| if (start < 0 || this.length < start || this.length < end) { | ||
| throw new RangeError("Out of range index"); | ||
| } | ||
| if (end <= start) { | ||
| return this; | ||
| } | ||
| start = start >>> 0; | ||
| end = end === undefined ? this.length : end >>> 0; | ||
| if (!val) { | ||
| val = 0; | ||
| } | ||
| let i; | ||
| if (typeof val === "number") { | ||
| for (i = start; i < end; ++i) { | ||
| this[i] = val; | ||
| } | ||
| } else { | ||
| const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); | ||
| const len = bytes.length; | ||
| if (len === 0) { | ||
| throw new TypeError( | ||
| 'The value "' + val + '" is invalid for argument "value"' | ||
| ); | ||
| } | ||
| for (i = 0; i < end - start; ++i) { | ||
| this[i + start] = bytes[i % len]; | ||
| } | ||
| } | ||
| return this; | ||
| }; | ||
| const errors = {}; | ||
| function E(sym, getMessage, Base) { | ||
| errors[sym] = class NodeError extends Base { | ||
| constructor() { | ||
| super(); | ||
| Object.defineProperty(this, "message", { | ||
| value: Reflect.apply(getMessage, this, arguments), | ||
| writable: true, | ||
| configurable: true | ||
| }); | ||
| this.name = `${this.name} [${sym}]`; | ||
| this.stack; | ||
| delete this.name; | ||
| } | ||
| get code() { | ||
| return sym; | ||
| } | ||
| set code(value) { | ||
| Object.defineProperty(this, "code", { | ||
| configurable: true, | ||
| enumerable: true, | ||
| value, | ||
| writable: true | ||
| }); | ||
| } | ||
| toString() { | ||
| return `${this.name} [${sym}]: ${this.message}`; | ||
| } | ||
| }; | ||
| } | ||
| E( | ||
| "ERR_BUFFER_OUT_OF_BOUNDS", | ||
| function(name) { | ||
| if (name) { | ||
| return `${name} is outside of buffer bounds`; | ||
| } | ||
| return "Attempt to access memory outside buffer bounds"; | ||
| }, | ||
| RangeError | ||
| ); | ||
| E( | ||
| "ERR_INVALID_ARG_TYPE", | ||
| function(name, actual) { | ||
| return `The "${name}" argument must be of type number. Received type ${typeof actual}`; | ||
| }, | ||
| TypeError | ||
| ); | ||
| E( | ||
| "ERR_OUT_OF_RANGE", | ||
| function(str, range, input) { | ||
| let msg = `The value of "${str}" is out of range.`; | ||
| let received = input; | ||
| if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { | ||
| received = addNumericalSeparator(String(input)); | ||
| } else if (typeof input === "bigint") { | ||
| received = String(input); | ||
| if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) { | ||
| received = addNumericalSeparator(received); | ||
| } | ||
| received += "n"; | ||
| } | ||
| msg += ` It must be ${range}. Received ${received}`; | ||
| return msg; | ||
| }, | ||
| RangeError | ||
| ); | ||
| function addNumericalSeparator(val) { | ||
| let res = ""; | ||
| let i = val.length; | ||
| const start = val[0] === "-" ? 1 : 0; | ||
| for (; i >= start + 4; i -= 3) { | ||
| res = `_${val.slice(i - 3, i)}${res}`; | ||
| } | ||
| return `${val.slice(0, i)}${res}`; | ||
| } | ||
| function checkBounds(buf, offset, byteLength2) { | ||
| validateNumber(offset, "offset"); | ||
| if (buf[offset] === undefined || buf[offset + byteLength2] === undefined) { | ||
| boundsError(offset, buf.length - (byteLength2 + 1)); | ||
| } | ||
| } | ||
| function checkIntBI(value, min, max, buf, offset, byteLength2) { | ||
| if (value > max || value < min) { | ||
| const n = typeof min === "bigint" ? "n" : ""; | ||
| let range; | ||
| { | ||
| range = min === 0 || min === BigInt(0) ? `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}` : `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`; | ||
| } | ||
| throw new errors.ERR_OUT_OF_RANGE("value", range, value); | ||
| } | ||
| checkBounds(buf, offset, byteLength2); | ||
| } | ||
| function validateNumber(value, name) { | ||
| if (typeof value !== "number") { | ||
| throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value); | ||
| } | ||
| } | ||
| function boundsError(value, length, type) { | ||
| if (Math.floor(value) !== value) { | ||
| validateNumber(value, type); | ||
| throw new errors.ERR_OUT_OF_RANGE("offset", "an integer", value); | ||
| } | ||
| if (length < 0) { | ||
| throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); | ||
| } | ||
| throw new errors.ERR_OUT_OF_RANGE( | ||
| "offset", | ||
| `>= ${0} and <= ${length}`, | ||
| value | ||
| ); | ||
| } | ||
| const INVALID_BASE64_RE = /[^\w+/-]/g; | ||
| function base64clean(str) { | ||
| str = str.split("=")[0]; | ||
| str = str.trim().replace(INVALID_BASE64_RE, ""); | ||
| if (str.length < 2) { | ||
| return ""; | ||
| } | ||
| while (str.length % 4 !== 0) { | ||
| str = str + "="; | ||
| } | ||
| return str; | ||
| } | ||
| function utf8ToBytes(string, units) { | ||
| units = units || Number.POSITIVE_INFINITY; | ||
| let codePoint; | ||
| const length = string.length; | ||
| let leadSurrogate = null; | ||
| const bytes = []; | ||
| for (let i = 0; i < length; ++i) { | ||
| codePoint = string.charCodeAt(i); | ||
| if (codePoint > 55295 && codePoint < 57344) { | ||
| if (!leadSurrogate) { | ||
| if (codePoint > 56319) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| continue; | ||
| } else if (i + 1 === length) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| continue; | ||
| } | ||
| leadSurrogate = codePoint; | ||
| continue; | ||
| } | ||
| if (codePoint < 56320) { | ||
| if ((units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| leadSurrogate = codePoint; | ||
| continue; | ||
| } | ||
| codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; | ||
| } else if (leadSurrogate && // valid bmp char, but last char was a lead | ||
| (units -= 3) > -1) { | ||
| bytes.push(239, 191, 189); | ||
| } | ||
| leadSurrogate = null; | ||
| if (codePoint < 128) { | ||
| if ((units -= 1) < 0) { | ||
| break; | ||
| } | ||
| bytes.push(codePoint); | ||
| } else if (codePoint < 2048) { | ||
| if ((units -= 2) < 0) { | ||
| break; | ||
| } | ||
| bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128); | ||
| } else if (codePoint < 65536) { | ||
| if ((units -= 3) < 0) { | ||
| break; | ||
| } | ||
| bytes.push( | ||
| codePoint >> 12 | 224, | ||
| codePoint >> 6 & 63 | 128, | ||
| codePoint & 63 | 128 | ||
| ); | ||
| } else if (codePoint < 1114112) { | ||
| if ((units -= 4) < 0) { | ||
| break; | ||
| } | ||
| bytes.push( | ||
| codePoint >> 18 | 240, | ||
| codePoint >> 12 & 63 | 128, | ||
| codePoint >> 6 & 63 | 128, | ||
| codePoint & 63 | 128 | ||
| ); | ||
| } else { | ||
| throw new Error("Invalid code point"); | ||
| } | ||
| } | ||
| return bytes; | ||
| } | ||
| function asciiToBytes(str) { | ||
| const byteArray = []; | ||
| for (let i = 0; i < str.length; ++i) { | ||
| byteArray.push(str.charCodeAt(i) & 255); | ||
| } | ||
| return byteArray; | ||
| } | ||
| function utf16leToBytes(str, units) { | ||
| let c, hi, lo; | ||
| const byteArray = []; | ||
| for (let i = 0; i < str.length; ++i) { | ||
| if ((units -= 2) < 0) { | ||
| break; | ||
| } | ||
| c = str.charCodeAt(i); | ||
| hi = c >> 8; | ||
| lo = c % 256; | ||
| byteArray.push(lo, hi); | ||
| } | ||
| return byteArray; | ||
| } | ||
| function base64ToBytes(str) { | ||
| return toByteArray(base64clean(str)); | ||
| } | ||
| function blitBuffer(src, dst, offset, length) { | ||
| let i; | ||
| for (i = 0; i < length; ++i) { | ||
| if (i + offset >= dst.length || i >= src.length) { | ||
| break; | ||
| } | ||
| dst[i + offset] = src[i]; | ||
| } | ||
| return i; | ||
| } | ||
| function isInstance(obj, type) { | ||
| return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; | ||
| } | ||
| function numberIsNaN(obj) { | ||
| return obj !== obj; | ||
| } | ||
| const hexSliceLookupTable = function() { | ||
| const alphabet = "0123456789abcdef"; | ||
| const table = Array.from({ length: 256 }); | ||
| for (let i = 0; i < 16; ++i) { | ||
| const i16 = i * 16; | ||
| for (let j = 0; j < 16; ++j) { | ||
| table[i16 + j] = alphabet[i] + alphabet[j]; | ||
| } | ||
| } | ||
| return table; | ||
| }(); | ||
| function defineBigIntMethod(fn) { | ||
| return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; | ||
| } | ||
| function BufferBigIntNotDefined() { | ||
| throw new Error("BigInt not supported"); | ||
| } | ||
| export { Buffer }; |
@@ -1,1 +0,7 @@ | ||
| "use strict";const node_events=require("node:events");exports.EventEmitter=node_events.EventEmitter; | ||
| 'use strict'; | ||
| const node_events = require('node:events'); | ||
| exports.EventEmitter = node_events.EventEmitter; |
@@ -1,1 +0,1 @@ | ||
| export{EventEmitter}from"node:events"; | ||
| export { EventEmitter } from 'node:events'; |
@@ -1,1 +0,183 @@ | ||
| "use strict";let u=10;class EventEmitter{__unenv__={};_events=Object.create(null);_maxListeners;static get defaultMaxListeners(){return u}static set defaultMaxListeners(e){if(typeof e!="number"||e<0||Number.isNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}setMaxListeners(e){if(typeof e!="number"||e<0||Number.isNaN(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this}getMaxListeners(){return v(this)}emit(e,...r){if(!this._events[e]||this._events[e].length===0)return!1;if(e==="error"){let n;if(r.length>0&&(n=r[0]),n instanceof Error)throw n;const s=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw s.context=n,s}for(const n of this._events[e])(n.listener||n).apply(this,r);return!0}addListener(e,r){return o(this,e,r,!1)}on(e,r){return o(this,e,r,!1)}prependListener(e,r){return o(this,e,r,!0)}once(e,r){return this.on(e,f(this,e,r))}prependOnceListener(e,r){return this.prependListener(e,f(this,e,r))}removeListener(e,r){return E(this,e,r)}off(e,r){return this.removeListener(e,r)}removeAllListeners(e){return d(this,e)}listeners(e){return l(this,e,!0)}rawListeners(e){return l(this,e,!1)}listenerCount(e){return this.rawListeners(e).length}eventNames(){return Object.keys(this._events)}}function o(t,e,r,n){c(r),t._events.newListener!==void 0&&t.emit("newListener",e,r.listener||r),t._events[e]||(t._events[e]=[]),n?t._events[e].unshift(r):t._events[e].push(r);const s=v(t);if(s>0&&t._events[e].length>s&&!t._events[e].warned){t._events[e].warned=!0;const i=new Error(`[unenv] Possible EventEmitter memory leak detected. ${t._events[e].length} ${e} listeners added. Use emitter.setMaxListeners() to increase limit`);i.name="MaxListenersExceededWarning",i.emitter=t,i.type=e,i.count=t._events[e]?.length,console.warn(i)}return t}function E(t,e,r){if(c(r),!t._events[e]||t._events[e].length===0)return t;const n=t._events[e].length;return t._events[e]=t._events[e].filter(s=>s!==r),n===t._events[e].length||(t._events.removeListener&&t.emit("removeListener",e,r.listener||r),t._events[e].length===0&&delete t._events[e]),t}function d(t,e){if(!e)return t._events=Object.create(null),t;if(!t._events[e]||t._events[e].length===0)return t;if(t._events.removeListener)for(const r of t._events[e])t.emit("removeListener",e,r.listener||r);return delete t._events[e],t}function f(t,e,r){let n=!1;const s=(...i)=>{if(!n)return t.removeListener(e,s),n=!0,i.length===0?r.call(t):r.apply(t,i)};return s.listener=r,s}function v(t){return t._maxListeners??EventEmitter.defaultMaxListeners}function l(t,e,r){let n=t._events[e]||[];return typeof n=="function"&&(n=[n]),r?n.map(s=>s.listener||s):n}function c(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}exports.EventEmitter=EventEmitter; | ||
| 'use strict'; | ||
| let defaultMaxListeners = 10; | ||
| class EventEmitter { | ||
| __unenv__ = {}; | ||
| _events = /* @__PURE__ */ Object.create(null); | ||
| _maxListeners; | ||
| static get defaultMaxListeners() { | ||
| return defaultMaxListeners; | ||
| } | ||
| static set defaultMaxListeners(arg) { | ||
| if (typeof arg !== "number" || arg < 0 || Number.isNaN(arg)) { | ||
| throw new RangeError( | ||
| 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "." | ||
| ); | ||
| } | ||
| defaultMaxListeners = arg; | ||
| } | ||
| setMaxListeners(n) { | ||
| if (typeof n !== "number" || n < 0 || Number.isNaN(n)) { | ||
| throw new RangeError( | ||
| 'The value of "n" is out of range. It must be a non-negative number. Received ' + n + "." | ||
| ); | ||
| } | ||
| this._maxListeners = n; | ||
| return this; | ||
| } | ||
| getMaxListeners() { | ||
| return _getMaxListeners(this); | ||
| } | ||
| emit(type, ...args) { | ||
| if (!this._events[type] || this._events[type].length === 0) { | ||
| return false; | ||
| } | ||
| if (type === "error") { | ||
| let er; | ||
| if (args.length > 0) { | ||
| er = args[0]; | ||
| } | ||
| if (er instanceof Error) { | ||
| throw er; | ||
| } | ||
| const err = new Error( | ||
| "Unhandled error." + (er ? " (" + er.message + ")" : "") | ||
| ); | ||
| err.context = er; | ||
| throw err; | ||
| } | ||
| for (const _listener of this._events[type]) { | ||
| (_listener.listener || _listener).apply(this, args); | ||
| } | ||
| return true; | ||
| } | ||
| addListener(type, listener) { | ||
| return _addListener(this, type, listener, false); | ||
| } | ||
| on(type, listener) { | ||
| return _addListener(this, type, listener, false); | ||
| } | ||
| prependListener(type, listener) { | ||
| return _addListener(this, type, listener, true); | ||
| } | ||
| once(type, listener) { | ||
| return this.on(type, _wrapOnce(this, type, listener)); | ||
| } | ||
| prependOnceListener(type, listener) { | ||
| return this.prependListener(type, _wrapOnce(this, type, listener)); | ||
| } | ||
| removeListener(type, listener) { | ||
| return _removeListener(this, type, listener); | ||
| } | ||
| off(type, listener) { | ||
| return this.removeListener(type, listener); | ||
| } | ||
| removeAllListeners(type) { | ||
| return _removeAllListeners(this, type); | ||
| } | ||
| listeners(type) { | ||
| return _listeners(this, type, true); | ||
| } | ||
| rawListeners(type) { | ||
| return _listeners(this, type, false); | ||
| } | ||
| listenerCount(type) { | ||
| return this.rawListeners(type).length; | ||
| } | ||
| eventNames() { | ||
| return Object.keys(this._events); | ||
| } | ||
| } | ||
| function _addListener(target, type, listener, prepend) { | ||
| _checkListener(listener); | ||
| if (target._events.newListener !== undefined) { | ||
| target.emit("newListener", type, listener.listener || listener); | ||
| } | ||
| if (!target._events[type]) { | ||
| target._events[type] = []; | ||
| } | ||
| if (prepend) { | ||
| target._events[type].unshift(listener); | ||
| } else { | ||
| target._events[type].push(listener); | ||
| } | ||
| const maxListeners = _getMaxListeners(target); | ||
| if (maxListeners > 0 && target._events[type].length > maxListeners && !target._events[type].warned) { | ||
| target._events[type].warned = true; | ||
| const warning = new Error( | ||
| `[unenv] Possible EventEmitter memory leak detected. ${target._events[type].length} ${type} listeners added. Use emitter.setMaxListeners() to increase limit` | ||
| ); | ||
| warning.name = "MaxListenersExceededWarning"; | ||
| warning.emitter = target; | ||
| warning.type = type; | ||
| warning.count = target._events[type]?.length; | ||
| console.warn(warning); | ||
| } | ||
| return target; | ||
| } | ||
| function _removeListener(target, type, listener) { | ||
| _checkListener(listener); | ||
| if (!target._events[type] || target._events[type].length === 0) { | ||
| return target; | ||
| } | ||
| const lenBeforeFilter = target._events[type].length; | ||
| target._events[type] = target._events[type].filter((fn) => fn !== listener); | ||
| if (lenBeforeFilter === target._events[type].length) { | ||
| return target; | ||
| } | ||
| if (target._events.removeListener) { | ||
| target.emit("removeListener", type, listener.listener || listener); | ||
| } | ||
| if (target._events[type].length === 0) { | ||
| delete target._events[type]; | ||
| } | ||
| return target; | ||
| } | ||
| function _removeAllListeners(target, type) { | ||
| if (!type) { | ||
| target._events = /* @__PURE__ */ Object.create(null); | ||
| return target; | ||
| } | ||
| if (!target._events[type] || target._events[type].length === 0) { | ||
| return target; | ||
| } | ||
| if (target._events.removeListener) { | ||
| for (const _listener of target._events[type]) { | ||
| target.emit("removeListener", type, _listener.listener || _listener); | ||
| } | ||
| } | ||
| delete target._events[type]; | ||
| return target; | ||
| } | ||
| function _wrapOnce(target, type, listener) { | ||
| let fired = false; | ||
| const wrapper = (...args) => { | ||
| if (fired) { | ||
| return; | ||
| } | ||
| target.removeListener(type, wrapper); | ||
| fired = true; | ||
| return args.length === 0 ? listener.call(target) : listener.apply(target, args); | ||
| }; | ||
| wrapper.listener = listener; | ||
| return wrapper; | ||
| } | ||
| function _getMaxListeners(target) { | ||
| return target._maxListeners ?? EventEmitter.defaultMaxListeners; | ||
| } | ||
| function _listeners(target, type, unwrap) { | ||
| let listeners = target._events[type] || []; | ||
| if (typeof listeners === "function") { | ||
| listeners = [listeners]; | ||
| } | ||
| return unwrap ? listeners.map((l) => l.listener || l) : listeners; | ||
| } | ||
| function _checkListener(listener) { | ||
| if (typeof listener !== "function") { | ||
| throw new TypeError( | ||
| 'The "listener" argument must be of type Function. Received type ' + typeof listener | ||
| ); | ||
| } | ||
| } | ||
| exports.EventEmitter = EventEmitter; |
@@ -1,1 +0,181 @@ | ||
| let u=10;class a{__unenv__={};_events=Object.create(null);_maxListeners;static get defaultMaxListeners(){return u}static set defaultMaxListeners(e){if(typeof e!="number"||e<0||Number.isNaN(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}setMaxListeners(e){if(typeof e!="number"||e<0||Number.isNaN(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this}getMaxListeners(){return v(this)}emit(e,...r){if(!this._events[e]||this._events[e].length===0)return!1;if(e==="error"){let n;if(r.length>0&&(n=r[0]),n instanceof Error)throw n;const s=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw s.context=n,s}for(const n of this._events[e])(n.listener||n).apply(this,r);return!0}addListener(e,r){return o(this,e,r,!1)}on(e,r){return o(this,e,r,!1)}prependListener(e,r){return o(this,e,r,!0)}once(e,r){return this.on(e,l(this,e,r))}prependOnceListener(e,r){return this.prependListener(e,l(this,e,r))}removeListener(e,r){return c(this,e,r)}off(e,r){return this.removeListener(e,r)}removeAllListeners(e){return _(this,e)}listeners(e){return f(this,e,!0)}rawListeners(e){return f(this,e,!1)}listenerCount(e){return this.rawListeners(e).length}eventNames(){return Object.keys(this._events)}}function o(t,e,r,n){h(r),t._events.newListener!==void 0&&t.emit("newListener",e,r.listener||r),t._events[e]||(t._events[e]=[]),n?t._events[e].unshift(r):t._events[e].push(r);const s=v(t);if(s>0&&t._events[e].length>s&&!t._events[e].warned){t._events[e].warned=!0;const i=new Error(`[unenv] Possible EventEmitter memory leak detected. ${t._events[e].length} ${e} listeners added. Use emitter.setMaxListeners() to increase limit`);i.name="MaxListenersExceededWarning",i.emitter=t,i.type=e,i.count=t._events[e]?.length,console.warn(i)}return t}function c(t,e,r){if(h(r),!t._events[e]||t._events[e].length===0)return t;const n=t._events[e].length;return t._events[e]=t._events[e].filter(s=>s!==r),n===t._events[e].length||(t._events.removeListener&&t.emit("removeListener",e,r.listener||r),t._events[e].length===0&&delete t._events[e]),t}function _(t,e){if(!e)return t._events=Object.create(null),t;if(!t._events[e]||t._events[e].length===0)return t;if(t._events.removeListener)for(const r of t._events[e])t.emit("removeListener",e,r.listener||r);return delete t._events[e],t}function l(t,e,r){let n=!1;const s=(...i)=>{if(!n)return t.removeListener(e,s),n=!0,i.length===0?r.call(t):r.apply(t,i)};return s.listener=r,s}function v(t){return t._maxListeners??a.defaultMaxListeners}function f(t,e,r){let n=t._events[e]||[];return typeof n=="function"&&(n=[n]),r?n.map(s=>s.listener||s):n}function h(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}export{a as EventEmitter}; | ||
| let defaultMaxListeners = 10; | ||
| class EventEmitter { | ||
| __unenv__ = {}; | ||
| _events = /* @__PURE__ */ Object.create(null); | ||
| _maxListeners; | ||
| static get defaultMaxListeners() { | ||
| return defaultMaxListeners; | ||
| } | ||
| static set defaultMaxListeners(arg) { | ||
| if (typeof arg !== "number" || arg < 0 || Number.isNaN(arg)) { | ||
| throw new RangeError( | ||
| 'The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + "." | ||
| ); | ||
| } | ||
| defaultMaxListeners = arg; | ||
| } | ||
| setMaxListeners(n) { | ||
| if (typeof n !== "number" || n < 0 || Number.isNaN(n)) { | ||
| throw new RangeError( | ||
| 'The value of "n" is out of range. It must be a non-negative number. Received ' + n + "." | ||
| ); | ||
| } | ||
| this._maxListeners = n; | ||
| return this; | ||
| } | ||
| getMaxListeners() { | ||
| return _getMaxListeners(this); | ||
| } | ||
| emit(type, ...args) { | ||
| if (!this._events[type] || this._events[type].length === 0) { | ||
| return false; | ||
| } | ||
| if (type === "error") { | ||
| let er; | ||
| if (args.length > 0) { | ||
| er = args[0]; | ||
| } | ||
| if (er instanceof Error) { | ||
| throw er; | ||
| } | ||
| const err = new Error( | ||
| "Unhandled error." + (er ? " (" + er.message + ")" : "") | ||
| ); | ||
| err.context = er; | ||
| throw err; | ||
| } | ||
| for (const _listener of this._events[type]) { | ||
| (_listener.listener || _listener).apply(this, args); | ||
| } | ||
| return true; | ||
| } | ||
| addListener(type, listener) { | ||
| return _addListener(this, type, listener, false); | ||
| } | ||
| on(type, listener) { | ||
| return _addListener(this, type, listener, false); | ||
| } | ||
| prependListener(type, listener) { | ||
| return _addListener(this, type, listener, true); | ||
| } | ||
| once(type, listener) { | ||
| return this.on(type, _wrapOnce(this, type, listener)); | ||
| } | ||
| prependOnceListener(type, listener) { | ||
| return this.prependListener(type, _wrapOnce(this, type, listener)); | ||
| } | ||
| removeListener(type, listener) { | ||
| return _removeListener(this, type, listener); | ||
| } | ||
| off(type, listener) { | ||
| return this.removeListener(type, listener); | ||
| } | ||
| removeAllListeners(type) { | ||
| return _removeAllListeners(this, type); | ||
| } | ||
| listeners(type) { | ||
| return _listeners(this, type, true); | ||
| } | ||
| rawListeners(type) { | ||
| return _listeners(this, type, false); | ||
| } | ||
| listenerCount(type) { | ||
| return this.rawListeners(type).length; | ||
| } | ||
| eventNames() { | ||
| return Object.keys(this._events); | ||
| } | ||
| } | ||
| function _addListener(target, type, listener, prepend) { | ||
| _checkListener(listener); | ||
| if (target._events.newListener !== undefined) { | ||
| target.emit("newListener", type, listener.listener || listener); | ||
| } | ||
| if (!target._events[type]) { | ||
| target._events[type] = []; | ||
| } | ||
| if (prepend) { | ||
| target._events[type].unshift(listener); | ||
| } else { | ||
| target._events[type].push(listener); | ||
| } | ||
| const maxListeners = _getMaxListeners(target); | ||
| if (maxListeners > 0 && target._events[type].length > maxListeners && !target._events[type].warned) { | ||
| target._events[type].warned = true; | ||
| const warning = new Error( | ||
| `[unenv] Possible EventEmitter memory leak detected. ${target._events[type].length} ${type} listeners added. Use emitter.setMaxListeners() to increase limit` | ||
| ); | ||
| warning.name = "MaxListenersExceededWarning"; | ||
| warning.emitter = target; | ||
| warning.type = type; | ||
| warning.count = target._events[type]?.length; | ||
| console.warn(warning); | ||
| } | ||
| return target; | ||
| } | ||
| function _removeListener(target, type, listener) { | ||
| _checkListener(listener); | ||
| if (!target._events[type] || target._events[type].length === 0) { | ||
| return target; | ||
| } | ||
| const lenBeforeFilter = target._events[type].length; | ||
| target._events[type] = target._events[type].filter((fn) => fn !== listener); | ||
| if (lenBeforeFilter === target._events[type].length) { | ||
| return target; | ||
| } | ||
| if (target._events.removeListener) { | ||
| target.emit("removeListener", type, listener.listener || listener); | ||
| } | ||
| if (target._events[type].length === 0) { | ||
| delete target._events[type]; | ||
| } | ||
| return target; | ||
| } | ||
| function _removeAllListeners(target, type) { | ||
| if (!type) { | ||
| target._events = /* @__PURE__ */ Object.create(null); | ||
| return target; | ||
| } | ||
| if (!target._events[type] || target._events[type].length === 0) { | ||
| return target; | ||
| } | ||
| if (target._events.removeListener) { | ||
| for (const _listener of target._events[type]) { | ||
| target.emit("removeListener", type, _listener.listener || _listener); | ||
| } | ||
| } | ||
| delete target._events[type]; | ||
| return target; | ||
| } | ||
| function _wrapOnce(target, type, listener) { | ||
| let fired = false; | ||
| const wrapper = (...args) => { | ||
| if (fired) { | ||
| return; | ||
| } | ||
| target.removeListener(type, wrapper); | ||
| fired = true; | ||
| return args.length === 0 ? listener.call(target) : listener.apply(target, args); | ||
| }; | ||
| wrapper.listener = listener; | ||
| return wrapper; | ||
| } | ||
| function _getMaxListeners(target) { | ||
| return target._maxListeners ?? EventEmitter.defaultMaxListeners; | ||
| } | ||
| function _listeners(target, type, unwrap) { | ||
| let listeners = target._events[type] || []; | ||
| if (typeof listeners === "function") { | ||
| listeners = [listeners]; | ||
| } | ||
| return unwrap ? listeners.map((l) => l.listener || l) : listeners; | ||
| } | ||
| function _checkListener(listener) { | ||
| if (typeof listener !== "function") { | ||
| throw new TypeError( | ||
| 'The "listener" argument must be of type Function. Received type ' + typeof listener | ||
| ); | ||
| } | ||
| } | ||
| export { EventEmitter }; |
+565
-1
@@ -1,1 +0,565 @@ | ||
| "use strict";const events=require("node-mock-http/_polyfill/events"),buffer=require("node-mock-http/_polyfill/buffer");function createNotImplementedError(n){throw new Error(`${n} is not implemented yet!`)}class Readable extends events.EventEmitter{__unenv__={};readableEncoding=null;readableEnded=!0;readableFlowing=!1;readableHighWaterMark=0;readableLength=0;readableObjectMode=!1;readableAborted=!1;readableDidRead=!1;closed=!1;errored=null;readable=!1;destroyed=!1;static from(e,t){return new Readable(t)}constructor(e){super()}_read(e){}read(e){}setEncoding(e){return this}pause(){return this}resume(){return this}isPaused(){return!0}unpipe(e){return this}unshift(e,t){}wrap(e){return this}push(e,t){return!1}_destroy(e,t){this.removeAllListeners()}destroy(e){return this.destroyed=!0,this._destroy(e),this}pipe(e,t){return{}}compose(e,t){throw new Error("Method not implemented.")}[Symbol.asyncDispose](){return this.destroy(),Promise.resolve()}async*[Symbol.asyncIterator](){throw createNotImplementedError("Readable.asyncIterator")}iterator(e){throw createNotImplementedError("Readable.iterator")}map(e,t){throw createNotImplementedError("Readable.map")}filter(e,t){throw createNotImplementedError("Readable.filter")}forEach(e,t){throw createNotImplementedError("Readable.forEach")}reduce(e,t,r){throw createNotImplementedError("Readable.reduce")}find(e,t){throw createNotImplementedError("Readable.find")}findIndex(e,t){throw createNotImplementedError("Readable.findIndex")}some(e,t){throw createNotImplementedError("Readable.some")}toArray(e){throw createNotImplementedError("Readable.toArray")}every(e,t){throw createNotImplementedError("Readable.every")}flatMap(e,t){throw createNotImplementedError("Readable.flatMap")}drop(e,t){throw createNotImplementedError("Readable.drop")}take(e,t){throw createNotImplementedError("Readable.take")}asIndexedPairs(e){throw createNotImplementedError("Readable.asIndexedPairs")}}class Writable extends events.EventEmitter{__unenv__={};writable=!0;writableEnded=!1;writableFinished=!1;writableHighWaterMark=0;writableLength=0;writableObjectMode=!1;writableCorked=0;closed=!1;errored=null;writableNeedDrain=!1;destroyed=!1;_data;_encoding="utf8";constructor(e){super()}pipe(e,t){return{}}_write(e,t,r){if(this.writableEnded){r&&r();return}if(this._data===void 0)this._data=e;else{const s=typeof this._data=="string"?buffer.Buffer.from(this._data,this._encoding||t||"utf8"):this._data,i=typeof e=="string"?buffer.Buffer.from(e,t||this._encoding||"utf8"):e;this._data=buffer.Buffer.concat([s,i])}this._encoding=t,r&&r()}_writev(e,t){}_destroy(e,t){}_final(e){}write(e,t,r){const s=typeof t=="string"?this._encoding:"utf8",i=typeof t=="function"?t:typeof r=="function"?r:void 0;return this._write(e,s,i),!0}setDefaultEncoding(e){return this}end(e,t,r){const s=typeof e=="function"?e:typeof t=="function"?t:typeof r=="function"?r:void 0;if(this.writableEnded)return s&&s(),this;const i=e===s?void 0:e;if(i){const u=t===s?void 0:t;this.write(i,u,s)}return this.writableEnded=!0,this.writableFinished=!0,this.emit("close"),this.emit("finish"),this}cork(){}uncork(){}destroy(e){return this.destroyed=!0,delete this._data,this.removeAllListeners(),this}compose(e,t){throw new Error("Method not implemented.")}}const o$2=class{allowHalfOpen=!0;_destroy;constructor(e=new Readable,t=new Writable){Object.assign(this,e),Object.assign(this,t),this._destroy=a(e._destroy,t._destroy)}};function p$1(){return Object.assign(o$2.prototype,Readable.prototype),Object.assign(o$2.prototype,Writable.prototype),o$2}function a(...n){return function(...e){for(const t of n)t(...e)}}const Duplex=p$1();class Socket extends Duplex{__unenv__={};bufferSize=0;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!1;localAddress="";localPort=0;remoteAddress="";remoteFamily="";remotePort=0;autoSelectFamilyAttemptedAddresses=[];readyState="readOnly";constructor(e){super()}write(e,t,r){return!1}connect(e,t,r){return this}end(e,t,r){return this}setEncoding(e){return this}pause(){return this}resume(){return this}setTimeout(e,t){return this}setNoDelay(e){return this}setKeepAlive(e,t){return this}address(){return{}}unref(){return this}ref(){return this}destroySoon(){this.destroy()}resetAndDestroy(){const e=new Error("ERR_SOCKET_CLOSED");return e.code="ERR_SOCKET_CLOSED",this.destroy(e),this}}class IncomingMessage extends Readable{aborted=!1;httpVersion="1.1";httpVersionMajor=1;httpVersionMinor=1;complete=!0;connection;socket;headers={};trailers={};method="GET";url="/";statusCode=200;statusMessage="";closed=!1;errored=null;readable=!1;constructor(e){super(),this.socket=this.connection=e||new Socket}get rawHeaders(){const e=this.headers,t=[];for(const r in e)if(Array.isArray(e[r]))for(const s of e[r])t.push(r,s);else t.push(r,e[r]);return t}get rawTrailers(){return[]}setTimeout(e,t){return this}get headersDistinct(){return o$1(this.headers)}get trailersDistinct(){return o$1(this.trailers)}}function o$1(n){const e={};for(const[t,r]of Object.entries(n))t&&(e[t]=(Array.isArray(r)?r:[r]).filter(Boolean));return e}class ServerResponse extends Writable{statusCode=200;statusMessage="";upgrading=!1;chunkedEncoding=!1;shouldKeepAlive=!1;useChunkedEncodingByDefault=!1;sendDate=!1;finished=!1;headersSent=!1;strictContentLength=!1;connection=null;socket=null;req;_headers={};constructor(e){super(),this.req=e}assignSocket(e){e._httpMessage=this,this.socket=e,this.connection=e,this.emit("socket",e),this._flush()}_flush(){this.flushHeaders()}detachSocket(e){}writeContinue(e){}writeHead(e,t,r){e&&(this.statusCode=e),typeof t=="string"&&(this.statusMessage=t,t=void 0);const s=r||t;if(s&&!Array.isArray(s))for(const i in s)this.setHeader(i,s[i]);return this.headersSent=!0,this}writeProcessing(){}setTimeout(e,t){return this}appendHeader(e,t){e=e.toLowerCase();const r=this._headers[e],s=[...Array.isArray(r)?r:[r],...Array.isArray(t)?t:[t]].filter(Boolean);return this._headers[e]=s.length>1?s:s[0],this}setHeader(e,t){return this._headers[e.toLowerCase()]=t,this}setHeaders(e){for(const[t,r]of Object.entries(e))this.setHeader(t,r);return this}getHeader(e){return this._headers[e.toLowerCase()]}getHeaders(){return this._headers}getHeaderNames(){return Object.keys(this._headers)}hasHeader(e){return e.toLowerCase()in this._headers}removeHeader(e){delete this._headers[e.toLowerCase()]}addTrailers(e){}flushHeaders(){}writeEarlyHints(e,t){typeof t=="function"&&t()}}const NodeHeadersObj=(()=>{const n=function(){};return n.prototype=Object.create(null),n})();function toNodeRequestHeaders(n={}){const e=new NodeHeadersObj,t=Array.isArray(n)||o(n)?n:Object.entries(n);for(const[r,s]of t)if(s){if(e[r]===void 0){e[r]=s;continue}e[r]=[...Array.isArray(e[r])?e[r]:[e[r]],...Array.isArray(s)?s:[s]]}return e}function o(n){return typeof n?.entries=="function"}function toWebResponseHeaders(n={}){if(n instanceof Headers)return n;const e=new Headers;for(const[t,r]of Object.entries(n))if(r!==void 0){if(Array.isArray(r)){for(const s of r)e.append(t,String(s));continue}e.set(t,String(r))}return e}const p=new Set([101,204,205,304]);async function callNodeRequestHandler(n,e){const t=new IncomingMessage,r=new ServerResponse(t);t.url=e.url?.toString()||"/";let s;if(!t.url.startsWith("/")){const d=new URL(t.url);s=d.host,t.url=d.pathname+d.search+d.hash}t.method=e.method||"GET",t.headers=toNodeRequestHeaders(e.headers||{}),t.headers.host||(t.headers.host=e.host||s||"localhost"),t.connection.encrypted=t.connection.encrypted||e.protocol==="https",t.body=e.body||null,t.__unenv__=e.context,await n(t,r);let i=r._data;(p.has(r.statusCode)||t.method.toUpperCase()==="HEAD")&&(i=null,delete r._headers["content-length"]);const u={status:r.statusCode,statusText:r.statusMessage,headers:r._headers,body:i};return t.destroy(),r.destroy(),u}async function fetchNodeRequestHandler(n,e,t={}){try{const r=await callNodeRequestHandler(n,{url:e,...t});return new Response(r.body,{status:r.status,statusText:r.statusText,headers:toWebResponseHeaders(r.headers)})}catch(r){return new Response(r.toString(),{status:Number.parseInt(r.statusCode||r.code)||500,statusText:r.statusText})}}exports.IncomingMessage=IncomingMessage,exports.ServerResponse=ServerResponse,exports.callNodeRequestHandler=callNodeRequestHandler,exports.fetchNodeRequestHandler=fetchNodeRequestHandler; | ||
| 'use strict'; | ||
| const events = require('node-mock-http/_polyfill/events'); | ||
| const buffer = require('node-mock-http/_polyfill/buffer'); | ||
| function createNotImplementedError(name) { | ||
| throw new Error(`${name} is not implemented yet!`); | ||
| } | ||
| class Readable extends events.EventEmitter { | ||
| __unenv__ = {}; | ||
| readableEncoding = null; | ||
| readableEnded = true; | ||
| readableFlowing = false; | ||
| readableHighWaterMark = 0; | ||
| readableLength = 0; | ||
| readableObjectMode = false; | ||
| readableAborted = false; | ||
| readableDidRead = false; | ||
| closed = false; | ||
| errored = null; | ||
| readable = false; | ||
| destroyed = false; | ||
| static from(_iterable, options) { | ||
| return new Readable(options); | ||
| } | ||
| constructor(_opts) { | ||
| super(); | ||
| } | ||
| _read(_size) { | ||
| } | ||
| read(_size) { | ||
| } | ||
| setEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| pause() { | ||
| return this; | ||
| } | ||
| resume() { | ||
| return this; | ||
| } | ||
| isPaused() { | ||
| return true; | ||
| } | ||
| unpipe(_destination) { | ||
| return this; | ||
| } | ||
| unshift(_chunk, _encoding) { | ||
| } | ||
| wrap(_oldStream) { | ||
| return this; | ||
| } | ||
| push(_chunk, _encoding) { | ||
| return false; | ||
| } | ||
| _destroy(_error, _callback) { | ||
| this.removeAllListeners(); | ||
| } | ||
| destroy(error) { | ||
| this.destroyed = true; | ||
| this._destroy(error); | ||
| return this; | ||
| } | ||
| pipe(_destenition, _options) { | ||
| return {}; | ||
| } | ||
| compose(_stream, _options) { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| [Symbol.asyncDispose]() { | ||
| this.destroy(); | ||
| return Promise.resolve(); | ||
| } | ||
| // eslint-disable-next-line require-yield | ||
| async *[Symbol.asyncIterator]() { | ||
| throw createNotImplementedError("Readable.asyncIterator"); | ||
| } | ||
| iterator(_options) { | ||
| throw createNotImplementedError("Readable.iterator"); | ||
| } | ||
| map(_fn, _options) { | ||
| throw createNotImplementedError("Readable.map"); | ||
| } | ||
| filter(_fn, _options) { | ||
| throw createNotImplementedError("Readable.filter"); | ||
| } | ||
| forEach(_fn, _options) { | ||
| throw createNotImplementedError("Readable.forEach"); | ||
| } | ||
| reduce(_fn, _initialValue, _options) { | ||
| throw createNotImplementedError("Readable.reduce"); | ||
| } | ||
| find(_fn, _options) { | ||
| throw createNotImplementedError("Readable.find"); | ||
| } | ||
| findIndex(_fn, _options) { | ||
| throw createNotImplementedError("Readable.findIndex"); | ||
| } | ||
| some(_fn, _options) { | ||
| throw createNotImplementedError("Readable.some"); | ||
| } | ||
| toArray(_options) { | ||
| throw createNotImplementedError("Readable.toArray"); | ||
| } | ||
| every(_fn, _options) { | ||
| throw createNotImplementedError("Readable.every"); | ||
| } | ||
| flatMap(_fn, _options) { | ||
| throw createNotImplementedError("Readable.flatMap"); | ||
| } | ||
| drop(_limit, _options) { | ||
| throw createNotImplementedError("Readable.drop"); | ||
| } | ||
| take(_limit, _options) { | ||
| throw createNotImplementedError("Readable.take"); | ||
| } | ||
| asIndexedPairs(_options) { | ||
| throw createNotImplementedError("Readable.asIndexedPairs"); | ||
| } | ||
| } | ||
| class Writable extends events.EventEmitter { | ||
| __unenv__ = {}; | ||
| writable = true; | ||
| writableEnded = false; | ||
| writableFinished = false; | ||
| writableHighWaterMark = 0; | ||
| writableLength = 0; | ||
| writableObjectMode = false; | ||
| writableCorked = 0; | ||
| closed = false; | ||
| errored = null; | ||
| writableNeedDrain = false; | ||
| destroyed = false; | ||
| _data; | ||
| _encoding = "utf8"; | ||
| constructor(_opts) { | ||
| super(); | ||
| } | ||
| pipe(_destenition, _options) { | ||
| return {}; | ||
| } | ||
| _write(chunk, encoding, callback) { | ||
| if (this.writableEnded) { | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| return; | ||
| } | ||
| if (this._data === undefined) { | ||
| this._data = chunk; | ||
| } else { | ||
| const a = typeof this._data === "string" ? buffer.Buffer.from(this._data, this._encoding || encoding || "utf8") : this._data; | ||
| const b = typeof chunk === "string" ? buffer.Buffer.from(chunk, encoding || this._encoding || "utf8") : chunk; | ||
| this._data = buffer.Buffer.concat([a, b]); | ||
| } | ||
| this._encoding = encoding; | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| } | ||
| _writev(_chunks, _callback) { | ||
| } | ||
| _destroy(_error, _callback) { | ||
| } | ||
| _final(_callback) { | ||
| } | ||
| write(chunk, arg2, arg3) { | ||
| const encoding = typeof arg2 === "string" ? this._encoding : "utf8"; | ||
| const cb = typeof arg2 === "function" ? arg2 : typeof arg3 === "function" ? arg3 : undefined; | ||
| this._write(chunk, encoding, cb); | ||
| return true; | ||
| } | ||
| setDefaultEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| end(arg1, arg2, arg3) { | ||
| const callback = typeof arg1 === "function" ? arg1 : typeof arg2 === "function" ? arg2 : typeof arg3 === "function" ? arg3 : undefined; | ||
| if (this.writableEnded) { | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| return this; | ||
| } | ||
| const data = arg1 === callback ? undefined : arg1; | ||
| if (data) { | ||
| const encoding = arg2 === callback ? undefined : arg2; | ||
| this.write(data, encoding, callback); | ||
| } | ||
| this.writableEnded = true; | ||
| this.writableFinished = true; | ||
| this.emit("close"); | ||
| this.emit("finish"); | ||
| return this; | ||
| } | ||
| cork() { | ||
| } | ||
| uncork() { | ||
| } | ||
| destroy(_error) { | ||
| this.destroyed = true; | ||
| delete this._data; | ||
| this.removeAllListeners(); | ||
| return this; | ||
| } | ||
| compose(_stream, _options) { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| } | ||
| const __Duplex = class { | ||
| allowHalfOpen = true; | ||
| _destroy; | ||
| constructor(readable = new Readable(), writable = new Writable()) { | ||
| Object.assign(this, readable); | ||
| Object.assign(this, writable); | ||
| this._destroy = mergeFns(readable._destroy, writable._destroy); | ||
| } | ||
| }; | ||
| function getDuplex() { | ||
| Object.assign(__Duplex.prototype, Readable.prototype); | ||
| Object.assign(__Duplex.prototype, Writable.prototype); | ||
| return __Duplex; | ||
| } | ||
| function mergeFns(...functions) { | ||
| return function(...args) { | ||
| for (const fn of functions) { | ||
| fn(...args); | ||
| } | ||
| }; | ||
| } | ||
| const Duplex = /* @__PURE__ */ getDuplex(); | ||
| class Socket extends Duplex { | ||
| __unenv__ = {}; | ||
| bufferSize = 0; | ||
| bytesRead = 0; | ||
| bytesWritten = 0; | ||
| connecting = false; | ||
| destroyed = false; | ||
| pending = false; | ||
| localAddress = ""; | ||
| localPort = 0; | ||
| remoteAddress = ""; | ||
| remoteFamily = ""; | ||
| remotePort = 0; | ||
| autoSelectFamilyAttemptedAddresses = []; | ||
| readyState = "readOnly"; | ||
| constructor(_options) { | ||
| super(); | ||
| } | ||
| write(_buffer, _arg1, _arg2) { | ||
| return false; | ||
| } | ||
| connect(_arg1, _arg2, _arg3) { | ||
| return this; | ||
| } | ||
| end(_arg1, _arg2, _arg3) { | ||
| return this; | ||
| } | ||
| setEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| pause() { | ||
| return this; | ||
| } | ||
| resume() { | ||
| return this; | ||
| } | ||
| setTimeout(_timeout, _callback) { | ||
| return this; | ||
| } | ||
| setNoDelay(_noDelay) { | ||
| return this; | ||
| } | ||
| setKeepAlive(_enable, _initialDelay) { | ||
| return this; | ||
| } | ||
| address() { | ||
| return {}; | ||
| } | ||
| unref() { | ||
| return this; | ||
| } | ||
| ref() { | ||
| return this; | ||
| } | ||
| destroySoon() { | ||
| this.destroy(); | ||
| } | ||
| resetAndDestroy() { | ||
| const err = new Error("ERR_SOCKET_CLOSED"); | ||
| err.code = "ERR_SOCKET_CLOSED"; | ||
| this.destroy(err); | ||
| return this; | ||
| } | ||
| } | ||
| class IncomingMessage extends Readable { | ||
| aborted = false; | ||
| httpVersion = "1.1"; | ||
| httpVersionMajor = 1; | ||
| httpVersionMinor = 1; | ||
| complete = true; | ||
| connection; | ||
| socket; | ||
| headers = {}; | ||
| trailers = {}; | ||
| method = "GET"; | ||
| url = "/"; | ||
| statusCode = 200; | ||
| statusMessage = ""; | ||
| closed = false; | ||
| errored = null; | ||
| readable = false; | ||
| constructor(socket) { | ||
| super(); | ||
| this.socket = this.connection = socket || new Socket(); | ||
| } | ||
| get rawHeaders() { | ||
| const headers = this.headers; | ||
| const rawHeaders = []; | ||
| for (const key in headers) { | ||
| if (Array.isArray(headers[key])) { | ||
| for (const h of headers[key]) { | ||
| rawHeaders.push(key, h); | ||
| } | ||
| } else { | ||
| rawHeaders.push(key, headers[key]); | ||
| } | ||
| } | ||
| return rawHeaders; | ||
| } | ||
| get rawTrailers() { | ||
| return []; | ||
| } | ||
| setTimeout(_msecs, _callback) { | ||
| return this; | ||
| } | ||
| get headersDistinct() { | ||
| return _distinct(this.headers); | ||
| } | ||
| get trailersDistinct() { | ||
| return _distinct(this.trailers); | ||
| } | ||
| } | ||
| function _distinct(obj) { | ||
| const d = {}; | ||
| for (const [key, value] of Object.entries(obj)) { | ||
| if (key) { | ||
| d[key] = (Array.isArray(value) ? value : [value]).filter( | ||
| Boolean | ||
| ); | ||
| } | ||
| } | ||
| return d; | ||
| } | ||
| class ServerResponse extends Writable { | ||
| statusCode = 200; | ||
| statusMessage = ""; | ||
| upgrading = false; | ||
| chunkedEncoding = false; | ||
| shouldKeepAlive = false; | ||
| useChunkedEncodingByDefault = false; | ||
| sendDate = false; | ||
| finished = false; | ||
| headersSent = false; | ||
| strictContentLength = false; | ||
| connection = null; | ||
| socket = null; | ||
| req; | ||
| _headers = {}; | ||
| constructor(req) { | ||
| super(); | ||
| this.req = req; | ||
| } | ||
| assignSocket(socket) { | ||
| socket._httpMessage = this; | ||
| this.socket = socket; | ||
| this.connection = socket; | ||
| this.emit("socket", socket); | ||
| this._flush(); | ||
| } | ||
| _flush() { | ||
| this.flushHeaders(); | ||
| } | ||
| detachSocket(_socket) { | ||
| } | ||
| writeContinue(_callback) { | ||
| } | ||
| writeHead(statusCode, arg1, arg2) { | ||
| if (statusCode) { | ||
| this.statusCode = statusCode; | ||
| } | ||
| if (typeof arg1 === "string") { | ||
| this.statusMessage = arg1; | ||
| arg1 = undefined; | ||
| } | ||
| const headers = arg2 || arg1; | ||
| if (headers) { | ||
| if (Array.isArray(headers)) ; else { | ||
| for (const key in headers) { | ||
| this.setHeader(key, headers[key]); | ||
| } | ||
| } | ||
| } | ||
| this.headersSent = true; | ||
| return this; | ||
| } | ||
| writeProcessing() { | ||
| } | ||
| setTimeout(_msecs, _callback) { | ||
| return this; | ||
| } | ||
| appendHeader(name, value) { | ||
| name = name.toLowerCase(); | ||
| const current = this._headers[name]; | ||
| const all = [ | ||
| ...Array.isArray(current) ? current : [current], | ||
| ...Array.isArray(value) ? value : [value] | ||
| ].filter(Boolean); | ||
| this._headers[name] = all.length > 1 ? all : all[0]; | ||
| return this; | ||
| } | ||
| setHeader(name, value) { | ||
| this._headers[name.toLowerCase()] = value; | ||
| return this; | ||
| } | ||
| setHeaders(headers) { | ||
| for (const [key, value] of Object.entries(headers)) { | ||
| this.setHeader(key, value); | ||
| } | ||
| return this; | ||
| } | ||
| getHeader(name) { | ||
| return this._headers[name.toLowerCase()]; | ||
| } | ||
| getHeaders() { | ||
| return this._headers; | ||
| } | ||
| getHeaderNames() { | ||
| return Object.keys(this._headers); | ||
| } | ||
| hasHeader(name) { | ||
| return name.toLowerCase() in this._headers; | ||
| } | ||
| removeHeader(name) { | ||
| delete this._headers[name.toLowerCase()]; | ||
| } | ||
| addTrailers(_headers) { | ||
| } | ||
| flushHeaders() { | ||
| } | ||
| writeEarlyHints(_headers, cb) { | ||
| if (typeof cb === "function") { | ||
| cb(); | ||
| } | ||
| } | ||
| } | ||
| const NodeHeadersObj = /* @__PURE__ */ (() => { | ||
| const C = function() { | ||
| }; | ||
| C.prototype = /* @__PURE__ */ Object.create(null); | ||
| return C; | ||
| })(); | ||
| function toNodeRequestHeaders(headers = {}) { | ||
| const nodeHeaders = new NodeHeadersObj(); | ||
| const headerEntries = Array.isArray(headers) || _isinitHeaders(headers) ? headers : Object.entries(headers); | ||
| for (const [name, value] of headerEntries) { | ||
| if (!value) { | ||
| continue; | ||
| } | ||
| if (nodeHeaders[name] === undefined) { | ||
| nodeHeaders[name] = value; | ||
| continue; | ||
| } | ||
| nodeHeaders[name] = [ | ||
| ...Array.isArray(nodeHeaders[name]) ? nodeHeaders[name] : [nodeHeaders[name]], | ||
| ...Array.isArray(value) ? value : [value] | ||
| ]; | ||
| } | ||
| return nodeHeaders; | ||
| } | ||
| function _isinitHeaders(value) { | ||
| return typeof value?.entries === "function"; | ||
| } | ||
| function toWebResponseHeaders(headers = {}) { | ||
| if (headers instanceof Headers) { | ||
| return headers; | ||
| } | ||
| const webHeaders = new Headers(); | ||
| for (const [name, value] of Object.entries(headers)) { | ||
| if (value === undefined) { | ||
| continue; | ||
| } | ||
| if (Array.isArray(value)) { | ||
| for (const v of value) { | ||
| webHeaders.append(name, String(v)); | ||
| } | ||
| continue; | ||
| } | ||
| webHeaders.set(name, String(value)); | ||
| } | ||
| return webHeaders; | ||
| } | ||
| const nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]); | ||
| async function callNodeRequestHandler(handler, aRequest) { | ||
| const req = new IncomingMessage(); | ||
| const res = new ServerResponse(req); | ||
| req.url = aRequest.url?.toString() || "/"; | ||
| let hostFromURL; | ||
| if (!req.url.startsWith("/")) { | ||
| const url = new URL(req.url); | ||
| hostFromURL = url.host; | ||
| req.url = url.pathname + url.search + url.hash; | ||
| } | ||
| req.method = aRequest.method || "GET"; | ||
| req.headers = toNodeRequestHeaders(aRequest.headers || {}); | ||
| if (!req.headers.host) { | ||
| req.headers.host = aRequest.host || hostFromURL || "localhost"; | ||
| } | ||
| req.connection.encrypted = req.connection.encrypted || aRequest.protocol === "https"; | ||
| req.body = aRequest.body || null; | ||
| req.__unenv__ = aRequest.context; | ||
| await handler(req, res); | ||
| let responseBody = res._data; | ||
| if (nullBodyResponses.has(res.statusCode) || req.method.toUpperCase() === "HEAD") { | ||
| responseBody = null; | ||
| delete res._headers["content-length"]; | ||
| } | ||
| const response = { | ||
| status: res.statusCode, | ||
| statusText: res.statusMessage, | ||
| headers: res._headers, | ||
| body: responseBody | ||
| }; | ||
| req.destroy(); | ||
| res.destroy(); | ||
| return response; | ||
| } | ||
| async function fetchNodeRequestHandler(handler, url, init = {}) { | ||
| try { | ||
| const response = await callNodeRequestHandler(handler, { url, ...init }); | ||
| return new Response(response.body, { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| headers: toWebResponseHeaders(response.headers) | ||
| }); | ||
| } catch (error) { | ||
| return new Response(error.toString(), { | ||
| status: Number.parseInt(error.statusCode || error.code) || 500, | ||
| statusText: error.statusText | ||
| }); | ||
| } | ||
| } | ||
| exports.IncomingMessage = IncomingMessage; | ||
| exports.ServerResponse = ServerResponse; | ||
| exports.callNodeRequestHandler = callNodeRequestHandler; | ||
| exports.fetchNodeRequestHandler = fetchNodeRequestHandler; |
+560
-1
@@ -1,1 +0,560 @@ | ||
| import{EventEmitter as f}from"node-mock-http/_polyfill/events";import{Buffer as h}from"node-mock-http/_polyfill/buffer";function o(n){throw new Error(`${n} is not implemented yet!`)}class i extends f{__unenv__={};readableEncoding=null;readableEnded=!0;readableFlowing=!1;readableHighWaterMark=0;readableLength=0;readableObjectMode=!1;readableAborted=!1;readableDidRead=!1;closed=!1;errored=null;readable=!1;destroyed=!1;static from(e,t){return new i(t)}constructor(e){super()}_read(e){}read(e){}setEncoding(e){return this}pause(){return this}resume(){return this}isPaused(){return!0}unpipe(e){return this}unshift(e,t){}wrap(e){return this}push(e,t){return!1}_destroy(e,t){this.removeAllListeners()}destroy(e){return this.destroyed=!0,this._destroy(e),this}pipe(e,t){return{}}compose(e,t){throw new Error("Method not implemented.")}[Symbol.asyncDispose](){return this.destroy(),Promise.resolve()}async*[Symbol.asyncIterator](){throw o("Readable.asyncIterator")}iterator(e){throw o("Readable.iterator")}map(e,t){throw o("Readable.map")}filter(e,t){throw o("Readable.filter")}forEach(e,t){throw o("Readable.forEach")}reduce(e,t,r){throw o("Readable.reduce")}find(e,t){throw o("Readable.find")}findIndex(e,t){throw o("Readable.findIndex")}some(e,t){throw o("Readable.some")}toArray(e){throw o("Readable.toArray")}every(e,t){throw o("Readable.every")}flatMap(e,t){throw o("Readable.flatMap")}drop(e,t){throw o("Readable.drop")}take(e,t){throw o("Readable.take")}asIndexedPairs(e){throw o("Readable.asIndexedPairs")}}class l extends f{__unenv__={};writable=!0;writableEnded=!1;writableFinished=!1;writableHighWaterMark=0;writableLength=0;writableObjectMode=!1;writableCorked=0;closed=!1;errored=null;writableNeedDrain=!1;destroyed=!1;_data;_encoding="utf8";constructor(e){super()}pipe(e,t){return{}}_write(e,t,r){if(this.writableEnded){r&&r();return}if(this._data===void 0)this._data=e;else{const s=typeof this._data=="string"?h.from(this._data,this._encoding||t||"utf8"):this._data,a=typeof e=="string"?h.from(e,t||this._encoding||"utf8"):e;this._data=h.concat([s,a])}this._encoding=t,r&&r()}_writev(e,t){}_destroy(e,t){}_final(e){}write(e,t,r){const s=typeof t=="string"?this._encoding:"utf8",a=typeof t=="function"?t:typeof r=="function"?r:void 0;return this._write(e,s,a),!0}setDefaultEncoding(e){return this}end(e,t,r){const s=typeof e=="function"?e:typeof t=="function"?t:typeof r=="function"?r:void 0;if(this.writableEnded)return s&&s(),this;const a=e===s?void 0:e;if(a){const u=t===s?void 0:t;this.write(a,u,s)}return this.writableEnded=!0,this.writableFinished=!0,this.emit("close"),this.emit("finish"),this}cork(){}uncork(){}destroy(e){return this.destroyed=!0,delete this._data,this.removeAllListeners(),this}compose(e,t){throw new Error("Method not implemented.")}}const c=class{allowHalfOpen=!0;_destroy;constructor(e=new i,t=new l){Object.assign(this,e),Object.assign(this,t),this._destroy=g(e._destroy,t._destroy)}};function _(){return Object.assign(c.prototype,i.prototype),Object.assign(c.prototype,l.prototype),c}function g(...n){return function(...e){for(const t of n)t(...e)}}const m=_();class A extends m{__unenv__={};bufferSize=0;bytesRead=0;bytesWritten=0;connecting=!1;destroyed=!1;pending=!1;localAddress="";localPort=0;remoteAddress="";remoteFamily="";remotePort=0;autoSelectFamilyAttemptedAddresses=[];readyState="readOnly";constructor(e){super()}write(e,t,r){return!1}connect(e,t,r){return this}end(e,t,r){return this}setEncoding(e){return this}pause(){return this}resume(){return this}setTimeout(e,t){return this}setNoDelay(e){return this}setKeepAlive(e,t){return this}address(){return{}}unref(){return this}ref(){return this}destroySoon(){this.destroy()}resetAndDestroy(){const e=new Error("ERR_SOCKET_CLOSED");return e.code="ERR_SOCKET_CLOSED",this.destroy(e),this}}class y extends i{aborted=!1;httpVersion="1.1";httpVersionMajor=1;httpVersionMinor=1;complete=!0;connection;socket;headers={};trailers={};method="GET";url="/";statusCode=200;statusMessage="";closed=!1;errored=null;readable=!1;constructor(e){super(),this.socket=this.connection=e||new A}get rawHeaders(){const e=this.headers,t=[];for(const r in e)if(Array.isArray(e[r]))for(const s of e[r])t.push(r,s);else t.push(r,e[r]);return t}get rawTrailers(){return[]}setTimeout(e,t){return this}get headersDistinct(){return p(this.headers)}get trailersDistinct(){return p(this.trailers)}}function p(n){const e={};for(const[t,r]of Object.entries(n))t&&(e[t]=(Array.isArray(r)?r:[r]).filter(Boolean));return e}class w extends l{statusCode=200;statusMessage="";upgrading=!1;chunkedEncoding=!1;shouldKeepAlive=!1;useChunkedEncodingByDefault=!1;sendDate=!1;finished=!1;headersSent=!1;strictContentLength=!1;connection=null;socket=null;req;_headers={};constructor(e){super(),this.req=e}assignSocket(e){e._httpMessage=this,this.socket=e,this.connection=e,this.emit("socket",e),this._flush()}_flush(){this.flushHeaders()}detachSocket(e){}writeContinue(e){}writeHead(e,t,r){e&&(this.statusCode=e),typeof t=="string"&&(this.statusMessage=t,t=void 0);const s=r||t;if(s&&!Array.isArray(s))for(const a in s)this.setHeader(a,s[a]);return this.headersSent=!0,this}writeProcessing(){}setTimeout(e,t){return this}appendHeader(e,t){e=e.toLowerCase();const r=this._headers[e],s=[...Array.isArray(r)?r:[r],...Array.isArray(t)?t:[t]].filter(Boolean);return this._headers[e]=s.length>1?s:s[0],this}setHeader(e,t){return this._headers[e.toLowerCase()]=t,this}setHeaders(e){for(const[t,r]of Object.entries(e))this.setHeader(t,r);return this}getHeader(e){return this._headers[e.toLowerCase()]}getHeaders(){return this._headers}getHeaderNames(){return Object.keys(this._headers)}hasHeader(e){return e.toLowerCase()in this._headers}removeHeader(e){delete this._headers[e.toLowerCase()]}addTrailers(e){}flushHeaders(){}writeEarlyHints(e,t){typeof t=="function"&&t()}}const E=(()=>{const n=function(){};return n.prototype=Object.create(null),n})();function R(n={}){const e=new E,t=Array.isArray(n)||H(n)?n:Object.entries(n);for(const[r,s]of t)if(s){if(e[r]===void 0){e[r]=s;continue}e[r]=[...Array.isArray(e[r])?e[r]:[e[r]],...Array.isArray(s)?s:[s]]}return e}function H(n){return typeof n?.entries=="function"}function S(n={}){if(n instanceof Headers)return n;const e=new Headers;for(const[t,r]of Object.entries(n))if(r!==void 0){if(Array.isArray(r)){for(const s of r)e.append(t,String(s));continue}e.set(t,String(r))}return e}const C=new Set([101,204,205,304]);async function b(n,e){const t=new y,r=new w(t);t.url=e.url?.toString()||"/";let s;if(!t.url.startsWith("/")){const d=new URL(t.url);s=d.host,t.url=d.pathname+d.search+d.hash}t.method=e.method||"GET",t.headers=R(e.headers||{}),t.headers.host||(t.headers.host=e.host||s||"localhost"),t.connection.encrypted=t.connection.encrypted||e.protocol==="https",t.body=e.body||null,t.__unenv__=e.context,await n(t,r);let a=r._data;(C.has(r.statusCode)||t.method.toUpperCase()==="HEAD")&&(a=null,delete r._headers["content-length"]);const u={status:r.statusCode,statusText:r.statusMessage,headers:r._headers,body:a};return t.destroy(),r.destroy(),u}async function O(n,e,t={}){try{const r=await b(n,{url:e,...t});return new Response(r.body,{status:r.status,statusText:r.statusText,headers:S(r.headers)})}catch(r){return new Response(r.toString(),{status:Number.parseInt(r.statusCode||r.code)||500,statusText:r.statusText})}}export{y as IncomingMessage,w as ServerResponse,b as callNodeRequestHandler,O as fetchNodeRequestHandler}; | ||
| import { EventEmitter } from 'node-mock-http/_polyfill/events'; | ||
| import { Buffer } from 'node-mock-http/_polyfill/buffer'; | ||
| function createNotImplementedError(name) { | ||
| throw new Error(`${name} is not implemented yet!`); | ||
| } | ||
| class Readable extends EventEmitter { | ||
| __unenv__ = {}; | ||
| readableEncoding = null; | ||
| readableEnded = true; | ||
| readableFlowing = false; | ||
| readableHighWaterMark = 0; | ||
| readableLength = 0; | ||
| readableObjectMode = false; | ||
| readableAborted = false; | ||
| readableDidRead = false; | ||
| closed = false; | ||
| errored = null; | ||
| readable = false; | ||
| destroyed = false; | ||
| static from(_iterable, options) { | ||
| return new Readable(options); | ||
| } | ||
| constructor(_opts) { | ||
| super(); | ||
| } | ||
| _read(_size) { | ||
| } | ||
| read(_size) { | ||
| } | ||
| setEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| pause() { | ||
| return this; | ||
| } | ||
| resume() { | ||
| return this; | ||
| } | ||
| isPaused() { | ||
| return true; | ||
| } | ||
| unpipe(_destination) { | ||
| return this; | ||
| } | ||
| unshift(_chunk, _encoding) { | ||
| } | ||
| wrap(_oldStream) { | ||
| return this; | ||
| } | ||
| push(_chunk, _encoding) { | ||
| return false; | ||
| } | ||
| _destroy(_error, _callback) { | ||
| this.removeAllListeners(); | ||
| } | ||
| destroy(error) { | ||
| this.destroyed = true; | ||
| this._destroy(error); | ||
| return this; | ||
| } | ||
| pipe(_destenition, _options) { | ||
| return {}; | ||
| } | ||
| compose(_stream, _options) { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| [Symbol.asyncDispose]() { | ||
| this.destroy(); | ||
| return Promise.resolve(); | ||
| } | ||
| // eslint-disable-next-line require-yield | ||
| async *[Symbol.asyncIterator]() { | ||
| throw createNotImplementedError("Readable.asyncIterator"); | ||
| } | ||
| iterator(_options) { | ||
| throw createNotImplementedError("Readable.iterator"); | ||
| } | ||
| map(_fn, _options) { | ||
| throw createNotImplementedError("Readable.map"); | ||
| } | ||
| filter(_fn, _options) { | ||
| throw createNotImplementedError("Readable.filter"); | ||
| } | ||
| forEach(_fn, _options) { | ||
| throw createNotImplementedError("Readable.forEach"); | ||
| } | ||
| reduce(_fn, _initialValue, _options) { | ||
| throw createNotImplementedError("Readable.reduce"); | ||
| } | ||
| find(_fn, _options) { | ||
| throw createNotImplementedError("Readable.find"); | ||
| } | ||
| findIndex(_fn, _options) { | ||
| throw createNotImplementedError("Readable.findIndex"); | ||
| } | ||
| some(_fn, _options) { | ||
| throw createNotImplementedError("Readable.some"); | ||
| } | ||
| toArray(_options) { | ||
| throw createNotImplementedError("Readable.toArray"); | ||
| } | ||
| every(_fn, _options) { | ||
| throw createNotImplementedError("Readable.every"); | ||
| } | ||
| flatMap(_fn, _options) { | ||
| throw createNotImplementedError("Readable.flatMap"); | ||
| } | ||
| drop(_limit, _options) { | ||
| throw createNotImplementedError("Readable.drop"); | ||
| } | ||
| take(_limit, _options) { | ||
| throw createNotImplementedError("Readable.take"); | ||
| } | ||
| asIndexedPairs(_options) { | ||
| throw createNotImplementedError("Readable.asIndexedPairs"); | ||
| } | ||
| } | ||
| class Writable extends EventEmitter { | ||
| __unenv__ = {}; | ||
| writable = true; | ||
| writableEnded = false; | ||
| writableFinished = false; | ||
| writableHighWaterMark = 0; | ||
| writableLength = 0; | ||
| writableObjectMode = false; | ||
| writableCorked = 0; | ||
| closed = false; | ||
| errored = null; | ||
| writableNeedDrain = false; | ||
| destroyed = false; | ||
| _data; | ||
| _encoding = "utf8"; | ||
| constructor(_opts) { | ||
| super(); | ||
| } | ||
| pipe(_destenition, _options) { | ||
| return {}; | ||
| } | ||
| _write(chunk, encoding, callback) { | ||
| if (this.writableEnded) { | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| return; | ||
| } | ||
| if (this._data === undefined) { | ||
| this._data = chunk; | ||
| } else { | ||
| const a = typeof this._data === "string" ? Buffer.from(this._data, this._encoding || encoding || "utf8") : this._data; | ||
| const b = typeof chunk === "string" ? Buffer.from(chunk, encoding || this._encoding || "utf8") : chunk; | ||
| this._data = Buffer.concat([a, b]); | ||
| } | ||
| this._encoding = encoding; | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| } | ||
| _writev(_chunks, _callback) { | ||
| } | ||
| _destroy(_error, _callback) { | ||
| } | ||
| _final(_callback) { | ||
| } | ||
| write(chunk, arg2, arg3) { | ||
| const encoding = typeof arg2 === "string" ? this._encoding : "utf8"; | ||
| const cb = typeof arg2 === "function" ? arg2 : typeof arg3 === "function" ? arg3 : undefined; | ||
| this._write(chunk, encoding, cb); | ||
| return true; | ||
| } | ||
| setDefaultEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| end(arg1, arg2, arg3) { | ||
| const callback = typeof arg1 === "function" ? arg1 : typeof arg2 === "function" ? arg2 : typeof arg3 === "function" ? arg3 : undefined; | ||
| if (this.writableEnded) { | ||
| if (callback) { | ||
| callback(); | ||
| } | ||
| return this; | ||
| } | ||
| const data = arg1 === callback ? undefined : arg1; | ||
| if (data) { | ||
| const encoding = arg2 === callback ? undefined : arg2; | ||
| this.write(data, encoding, callback); | ||
| } | ||
| this.writableEnded = true; | ||
| this.writableFinished = true; | ||
| this.emit("close"); | ||
| this.emit("finish"); | ||
| return this; | ||
| } | ||
| cork() { | ||
| } | ||
| uncork() { | ||
| } | ||
| destroy(_error) { | ||
| this.destroyed = true; | ||
| delete this._data; | ||
| this.removeAllListeners(); | ||
| return this; | ||
| } | ||
| compose(_stream, _options) { | ||
| throw new Error("Method not implemented."); | ||
| } | ||
| } | ||
| const __Duplex = class { | ||
| allowHalfOpen = true; | ||
| _destroy; | ||
| constructor(readable = new Readable(), writable = new Writable()) { | ||
| Object.assign(this, readable); | ||
| Object.assign(this, writable); | ||
| this._destroy = mergeFns(readable._destroy, writable._destroy); | ||
| } | ||
| }; | ||
| function getDuplex() { | ||
| Object.assign(__Duplex.prototype, Readable.prototype); | ||
| Object.assign(__Duplex.prototype, Writable.prototype); | ||
| return __Duplex; | ||
| } | ||
| function mergeFns(...functions) { | ||
| return function(...args) { | ||
| for (const fn of functions) { | ||
| fn(...args); | ||
| } | ||
| }; | ||
| } | ||
| const Duplex = /* @__PURE__ */ getDuplex(); | ||
| class Socket extends Duplex { | ||
| __unenv__ = {}; | ||
| bufferSize = 0; | ||
| bytesRead = 0; | ||
| bytesWritten = 0; | ||
| connecting = false; | ||
| destroyed = false; | ||
| pending = false; | ||
| localAddress = ""; | ||
| localPort = 0; | ||
| remoteAddress = ""; | ||
| remoteFamily = ""; | ||
| remotePort = 0; | ||
| autoSelectFamilyAttemptedAddresses = []; | ||
| readyState = "readOnly"; | ||
| constructor(_options) { | ||
| super(); | ||
| } | ||
| write(_buffer, _arg1, _arg2) { | ||
| return false; | ||
| } | ||
| connect(_arg1, _arg2, _arg3) { | ||
| return this; | ||
| } | ||
| end(_arg1, _arg2, _arg3) { | ||
| return this; | ||
| } | ||
| setEncoding(_encoding) { | ||
| return this; | ||
| } | ||
| pause() { | ||
| return this; | ||
| } | ||
| resume() { | ||
| return this; | ||
| } | ||
| setTimeout(_timeout, _callback) { | ||
| return this; | ||
| } | ||
| setNoDelay(_noDelay) { | ||
| return this; | ||
| } | ||
| setKeepAlive(_enable, _initialDelay) { | ||
| return this; | ||
| } | ||
| address() { | ||
| return {}; | ||
| } | ||
| unref() { | ||
| return this; | ||
| } | ||
| ref() { | ||
| return this; | ||
| } | ||
| destroySoon() { | ||
| this.destroy(); | ||
| } | ||
| resetAndDestroy() { | ||
| const err = new Error("ERR_SOCKET_CLOSED"); | ||
| err.code = "ERR_SOCKET_CLOSED"; | ||
| this.destroy(err); | ||
| return this; | ||
| } | ||
| } | ||
| class IncomingMessage extends Readable { | ||
| aborted = false; | ||
| httpVersion = "1.1"; | ||
| httpVersionMajor = 1; | ||
| httpVersionMinor = 1; | ||
| complete = true; | ||
| connection; | ||
| socket; | ||
| headers = {}; | ||
| trailers = {}; | ||
| method = "GET"; | ||
| url = "/"; | ||
| statusCode = 200; | ||
| statusMessage = ""; | ||
| closed = false; | ||
| errored = null; | ||
| readable = false; | ||
| constructor(socket) { | ||
| super(); | ||
| this.socket = this.connection = socket || new Socket(); | ||
| } | ||
| get rawHeaders() { | ||
| const headers = this.headers; | ||
| const rawHeaders = []; | ||
| for (const key in headers) { | ||
| if (Array.isArray(headers[key])) { | ||
| for (const h of headers[key]) { | ||
| rawHeaders.push(key, h); | ||
| } | ||
| } else { | ||
| rawHeaders.push(key, headers[key]); | ||
| } | ||
| } | ||
| return rawHeaders; | ||
| } | ||
| get rawTrailers() { | ||
| return []; | ||
| } | ||
| setTimeout(_msecs, _callback) { | ||
| return this; | ||
| } | ||
| get headersDistinct() { | ||
| return _distinct(this.headers); | ||
| } | ||
| get trailersDistinct() { | ||
| return _distinct(this.trailers); | ||
| } | ||
| } | ||
| function _distinct(obj) { | ||
| const d = {}; | ||
| for (const [key, value] of Object.entries(obj)) { | ||
| if (key) { | ||
| d[key] = (Array.isArray(value) ? value : [value]).filter( | ||
| Boolean | ||
| ); | ||
| } | ||
| } | ||
| return d; | ||
| } | ||
| class ServerResponse extends Writable { | ||
| statusCode = 200; | ||
| statusMessage = ""; | ||
| upgrading = false; | ||
| chunkedEncoding = false; | ||
| shouldKeepAlive = false; | ||
| useChunkedEncodingByDefault = false; | ||
| sendDate = false; | ||
| finished = false; | ||
| headersSent = false; | ||
| strictContentLength = false; | ||
| connection = null; | ||
| socket = null; | ||
| req; | ||
| _headers = {}; | ||
| constructor(req) { | ||
| super(); | ||
| this.req = req; | ||
| } | ||
| assignSocket(socket) { | ||
| socket._httpMessage = this; | ||
| this.socket = socket; | ||
| this.connection = socket; | ||
| this.emit("socket", socket); | ||
| this._flush(); | ||
| } | ||
| _flush() { | ||
| this.flushHeaders(); | ||
| } | ||
| detachSocket(_socket) { | ||
| } | ||
| writeContinue(_callback) { | ||
| } | ||
| writeHead(statusCode, arg1, arg2) { | ||
| if (statusCode) { | ||
| this.statusCode = statusCode; | ||
| } | ||
| if (typeof arg1 === "string") { | ||
| this.statusMessage = arg1; | ||
| arg1 = undefined; | ||
| } | ||
| const headers = arg2 || arg1; | ||
| if (headers) { | ||
| if (Array.isArray(headers)) ; else { | ||
| for (const key in headers) { | ||
| this.setHeader(key, headers[key]); | ||
| } | ||
| } | ||
| } | ||
| this.headersSent = true; | ||
| return this; | ||
| } | ||
| writeProcessing() { | ||
| } | ||
| setTimeout(_msecs, _callback) { | ||
| return this; | ||
| } | ||
| appendHeader(name, value) { | ||
| name = name.toLowerCase(); | ||
| const current = this._headers[name]; | ||
| const all = [ | ||
| ...Array.isArray(current) ? current : [current], | ||
| ...Array.isArray(value) ? value : [value] | ||
| ].filter(Boolean); | ||
| this._headers[name] = all.length > 1 ? all : all[0]; | ||
| return this; | ||
| } | ||
| setHeader(name, value) { | ||
| this._headers[name.toLowerCase()] = value; | ||
| return this; | ||
| } | ||
| setHeaders(headers) { | ||
| for (const [key, value] of Object.entries(headers)) { | ||
| this.setHeader(key, value); | ||
| } | ||
| return this; | ||
| } | ||
| getHeader(name) { | ||
| return this._headers[name.toLowerCase()]; | ||
| } | ||
| getHeaders() { | ||
| return this._headers; | ||
| } | ||
| getHeaderNames() { | ||
| return Object.keys(this._headers); | ||
| } | ||
| hasHeader(name) { | ||
| return name.toLowerCase() in this._headers; | ||
| } | ||
| removeHeader(name) { | ||
| delete this._headers[name.toLowerCase()]; | ||
| } | ||
| addTrailers(_headers) { | ||
| } | ||
| flushHeaders() { | ||
| } | ||
| writeEarlyHints(_headers, cb) { | ||
| if (typeof cb === "function") { | ||
| cb(); | ||
| } | ||
| } | ||
| } | ||
| const NodeHeadersObj = /* @__PURE__ */ (() => { | ||
| const C = function() { | ||
| }; | ||
| C.prototype = /* @__PURE__ */ Object.create(null); | ||
| return C; | ||
| })(); | ||
| function toNodeRequestHeaders(headers = {}) { | ||
| const nodeHeaders = new NodeHeadersObj(); | ||
| const headerEntries = Array.isArray(headers) || _isinitHeaders(headers) ? headers : Object.entries(headers); | ||
| for (const [name, value] of headerEntries) { | ||
| if (!value) { | ||
| continue; | ||
| } | ||
| if (nodeHeaders[name] === undefined) { | ||
| nodeHeaders[name] = value; | ||
| continue; | ||
| } | ||
| nodeHeaders[name] = [ | ||
| ...Array.isArray(nodeHeaders[name]) ? nodeHeaders[name] : [nodeHeaders[name]], | ||
| ...Array.isArray(value) ? value : [value] | ||
| ]; | ||
| } | ||
| return nodeHeaders; | ||
| } | ||
| function _isinitHeaders(value) { | ||
| return typeof value?.entries === "function"; | ||
| } | ||
| function toWebResponseHeaders(headers = {}) { | ||
| if (headers instanceof Headers) { | ||
| return headers; | ||
| } | ||
| const webHeaders = new Headers(); | ||
| for (const [name, value] of Object.entries(headers)) { | ||
| if (value === undefined) { | ||
| continue; | ||
| } | ||
| if (Array.isArray(value)) { | ||
| for (const v of value) { | ||
| webHeaders.append(name, String(v)); | ||
| } | ||
| continue; | ||
| } | ||
| webHeaders.set(name, String(value)); | ||
| } | ||
| return webHeaders; | ||
| } | ||
| const nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]); | ||
| async function callNodeRequestHandler(handler, aRequest) { | ||
| const req = new IncomingMessage(); | ||
| const res = new ServerResponse(req); | ||
| req.url = aRequest.url?.toString() || "/"; | ||
| let hostFromURL; | ||
| if (!req.url.startsWith("/")) { | ||
| const url = new URL(req.url); | ||
| hostFromURL = url.host; | ||
| req.url = url.pathname + url.search + url.hash; | ||
| } | ||
| req.method = aRequest.method || "GET"; | ||
| req.headers = toNodeRequestHeaders(aRequest.headers || {}); | ||
| if (!req.headers.host) { | ||
| req.headers.host = aRequest.host || hostFromURL || "localhost"; | ||
| } | ||
| req.connection.encrypted = req.connection.encrypted || aRequest.protocol === "https"; | ||
| req.body = aRequest.body || null; | ||
| req.__unenv__ = aRequest.context; | ||
| await handler(req, res); | ||
| let responseBody = res._data; | ||
| if (nullBodyResponses.has(res.statusCode) || req.method.toUpperCase() === "HEAD") { | ||
| responseBody = null; | ||
| delete res._headers["content-length"]; | ||
| } | ||
| const response = { | ||
| status: res.statusCode, | ||
| statusText: res.statusMessage, | ||
| headers: res._headers, | ||
| body: responseBody | ||
| }; | ||
| req.destroy(); | ||
| res.destroy(); | ||
| return response; | ||
| } | ||
| async function fetchNodeRequestHandler(handler, url, init = {}) { | ||
| try { | ||
| const response = await callNodeRequestHandler(handler, { url, ...init }); | ||
| return new Response(response.body, { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| headers: toWebResponseHeaders(response.headers) | ||
| }); | ||
| } catch (error) { | ||
| return new Response(error.toString(), { | ||
| status: Number.parseInt(error.statusCode || error.code) || 500, | ||
| statusText: error.statusText | ||
| }); | ||
| } | ||
| } | ||
| export { IncomingMessage, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler }; |
+2
-2
| { | ||
| "name": "node-mock-http", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "", | ||
@@ -40,3 +40,3 @@ "repository": "unjs/node-mock-http", | ||
| "scripts": { | ||
| "build": "unbuild --minify", | ||
| "build": "unbuild", | ||
| "dev": "vitest dev --coverage", | ||
@@ -43,0 +43,0 @@ "lint": "eslint . && prettier -c .", |
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.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
194586
62.09%5806
920.39%2
-75%10
11.11%