🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

node-mock-http

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mock-http - npm Package Compare versions

Comparing version
0.0.0
to
0.1.0
+1
dist/_polyfill/buffer/node.cjs
"use strict";const node_buffer=require("node:buffer");exports.Buffer=node_buffer.Buffer;
export { Buffer } from 'node:buffer';
import 'node:events';
export { Buffer } from 'node:buffer';
import 'node:events';
export { Buffer } from 'node:buffer';
import 'node:events';
export{Buffer}from"node:buffer";
"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;
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
declare function Buffer(arg: any, encodingOrOffset: any, length: any): any;
declare namespace Buffer {
var TYPED_ARRAY_SUPPORT: boolean;
var poolSize: number;
var from: (value: any, encodingOrOffset: any, length?: any) => any;
var alloc: (size: any, fill: any, encoding: any) => Uint8Array<any>;
var allocUnsafe: (size: any) => Uint8Array<any>;
var allocUnsafeSlow: (size: any) => Uint8Array<any>;
var isBuffer: (b: any) => boolean;
var compare: (a: any, b: any) => 0 | 1 | -1;
var isEncoding: (encoding: any) => boolean;
var concat: (list: any, length?: any) => Uint8Array<any>;
var byteLength: (string: any, encoding: any) => any;
}
export { Buffer };
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
declare function Buffer(arg: any, encodingOrOffset: any, length: any): any;
declare namespace Buffer {
var TYPED_ARRAY_SUPPORT: boolean;
var poolSize: number;
var from: (value: any, encodingOrOffset: any, length?: any) => any;
var alloc: (size: any, fill: any, encoding: any) => Uint8Array<any>;
var allocUnsafe: (size: any) => Uint8Array<any>;
var allocUnsafeSlow: (size: any) => Uint8Array<any>;
var isBuffer: (b: any) => boolean;
var compare: (a: any, b: any) => 0 | 1 | -1;
var isEncoding: (encoding: any) => boolean;
var concat: (list: any, length?: any) => Uint8Array<any>;
var byteLength: (string: any, encoding: any) => any;
}
export { Buffer };
/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/
declare function Buffer(arg: any, encodingOrOffset: any, length: any): any;
declare namespace Buffer {
var TYPED_ARRAY_SUPPORT: boolean;
var poolSize: number;
var from: (value: any, encodingOrOffset: any, length?: any) => any;
var alloc: (size: any, fill: any, encoding: any) => Uint8Array<any>;
var allocUnsafe: (size: any) => Uint8Array<any>;
var allocUnsafeSlow: (size: any) => Uint8Array<any>;
var isBuffer: (b: any) => boolean;
var compare: (a: any, b: any) => 0 | 1 | -1;
var isEncoding: (encoding: any) => boolean;
var concat: (list: any, length?: any) => Uint8Array<any>;
var byteLength: (string: any, encoding: any) => any;
}
export { Buffer };
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};
"use strict";const node_events=require("node:events");exports.EventEmitter=node_events.EventEmitter;
export { EventEmitter } from 'node:events';
export { EventEmitter } from 'node:events';
export { EventEmitter } from 'node:events';
export{EventEmitter}from"node:events";
"use strict";let y=10;const Y=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),F=(t,e)=>t,g=Error,J=Error,h=Error,b=Error,Z=Error,R=Symbol.for("nodejs.rejection"),l=Symbol.for("kCapture"),A=Symbol.for("events.errorMonitor"),p=Symbol.for("shapeMode"),w=Symbol.for("events.maxEventTargetListeners"),ee=Symbol.for("kEnhanceStackBeforeInspector"),te=Symbol.for("nodejs.watermarkData"),E=Symbol.for("kAsyncResource"),ne=Symbol.for("kFirstEventParam"),N=Symbol.for("kResistStopPropagation"),W=Symbol.for("events.maxEventTargetListenersWarned");class EventEmitter{_events=void 0;_eventsCount=0;_maxListeners=y;[l]=!1;[p]=!1;static captureRejectionSymbol=R;static errorMonitor=A;static kMaxEventTargetListeners=w;static kMaxEventTargetListenersWarned=W;static usingDomains=!1;static get on(){return on}static get once(){return once}static get getEventListeners(){return getEventListeners}static get getMaxListeners(){return getMaxListeners}static get addAbortListener(){return addAbortListener}static get EventEmitterAsyncResource(){return EventEmitterAsyncResource}static get EventEmitter(){return EventEmitter}static setMaxListeners(e=y,...n){if(n.length===0)y=e;else for(const r of n)if(H(r))r[w]=e,r[W]=!1;else if(typeof r.setMaxListeners=="function")r.setMaxListeners(e);else throw new h("eventTargets",["EventEmitter","EventTarget"],r)}static listenerCount(e,n){if(typeof e.listenerCount=="function")return e.listenerCount(n);EventEmitter.prototype.listenerCount.call(e,n)}static init(){throw new Error("EventEmitter.init() is not implemented.")}static get captureRejections(){return this[l]}static set captureRejections(e){this[l]=e}static get defaultMaxListeners(){return y}static set defaultMaxListeners(e){y=e}constructor(e){this._events===void 0||this._events===Object.getPrototypeOf(this)._events?(this._events={__proto__:null},this._eventsCount=0,this[p]=!1):this[p]=!0,this._maxListeners=this._maxListeners||void 0,e?.captureRejections?this[l]=!!e.captureRejections:this[l]=EventEmitter.prototype[l]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return S(this)}emit(e,...n){let r=e==="error";const s=this._events;if(s!==void 0)r&&s[A]!==void 0&&this.emit(A,...n),r=r&&s.error===void 0;else if(!r)return!1;if(r){let i;if(n.length>0&&(i=n[0]),i instanceof Error){try{const a={};Error.captureStackTrace?.(a,EventEmitter.prototype.emit),Object.defineProperty(i,ee,{__proto__:null,value:Function.prototype.bind(se,this,i,a),configurable:!0})}catch{}throw i}let c;try{c=F(i)}catch{c=i}const f=new J(c);throw f.context=i,f}const o=s[e];if(o===void 0)return!1;if(typeof o=="function"){const i=o.apply(this,n);i!=null&&O(this,i,e,n)}else{const i=o.length,c=C(o);for(let f=0;f<i;++f){const a=c[f].apply(this,n);a!=null&&O(this,a,e,n)}}return!0}addListener(e,n){return z(this,e,n,!1),this}on(e,n){return this.addListener(e,n)}prependListener(e,n){return z(this,e,n,!0),this}once(e,n){return this.on(e,U(this,e,n)),this}prependOnceListener(e,n){return this.prependListener(e,U(this,e,n)),this}removeListener(e,n){const r=this._events;if(r===void 0)return this;const s=r[e];if(s===void 0)return this;if(s===n||s.listener===n)this._eventsCount-=1,this[p]?r[e]=void 0:this._eventsCount===0?this._events={__proto__:null}:(delete r[e],r.removeListener&&this.emit("removeListener",e,s.listener||n));else if(typeof s!="function"){let o=-1;for(let i=s.length-1;i>=0;i--)if(s[i]===n||s[i].listener===n){o=i;break}if(o<0)return this;o===0?s.shift():ce(s,o),s.length===1&&(r[e]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",e,n)}return this}off(e,n){return this.removeListener(e,n)}removeAllListeners(e){const n=this._events;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events={__proto__:null},this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events={__proto__:null}:delete n[e]),this[p]=!1,this;if(arguments.length===0){for(const s of Reflect.ownKeys(n))s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events={__proto__:null},this._eventsCount=0,this[p]=!1,this}const r=n[e];if(typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(let s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this}listeners(e){return G(this,e,!0)}rawListeners(e){return G(this,e,!1)}eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}listenerCount(e,n){const r=this._events;if(r!==void 0){const s=r[e];if(typeof s=="function")return n!=null?n===s||n===s.listener?1:0:1;if(s!==void 0){if(n!=null){let o=0;for(let i=0,c=s.length;i<c;i++)(s[i]===n||s[i].listener===n)&&o++;return o}return s.length}}return 0}}class EventEmitterAsyncResource extends EventEmitter{constructor(e){let n;typeof e=="string"?(n=e,e=void 0):n=e?.name||new.target.name,super(e),this[E]=new EventEmitterReferencingAsyncResource(this,n,e)}emit(e,...n){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");const{asyncResource:r}=this;return Array.prototype.unshift(n,super.emit,this,e),Reflect.apply(r.runInAsyncScope,r,n)}emitDestroy(){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");this.asyncResource.emitDestroy()}get asyncId(){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");return this.asyncResource.asyncId()}get triggerAsyncId(){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");return this.asyncResource.triggerAsyncId()}get asyncResource(){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");return this[E]}}const on=function(t,e,n={}){const r=n.signal;if(r?.aborted)throw new b(void 0,{cause:r?.reason});const s=n.highWaterMark??n.highWatermark??Number.MAX_SAFE_INTEGER,o=n.lowWaterMark??n.lowWatermark??1,i=new $,c=new $;let f=!1,a=null,d=!1,m=0;const I=Object.setPrototypeOf({next(){if(m){const u=i.shift();return m--,f&&m<o&&(t.resume?.(),f=!1),Promise.resolve(T(u,!1))}if(a){const u=Promise.reject(a);return a=null,u}return d?v():new Promise(function(u,V){c.push({resolve:u,reject:V})})},return(){return v()},throw(u){if(!u||!(u instanceof Error))throw new h("EventEmitter.AsyncIterator","Error",u);x(u)},[Symbol.asyncIterator](){return this},[te]:{get size(){return m},get low(){return o},get high(){return s},get isPaused(){return f}}},Y),{addEventListener:_,removeAll:K}=ue();_(t,e,n[ne]?j:function(...u){return j(u)}),e!=="error"&&typeof t.on=="function"&&_(t,"error",x);const k=n?.close;if(k?.length)for(const u of k)_(t,u,v);const q=r?addAbortListener(r,Q):null;return I;function Q(){x(new b(void 0,{cause:r?.reason}))}function j(u){c.isEmpty()?(m++,!f&&m>s&&(f=!0,t.pause?.()),i.push(u)):c.shift().resolve(T(u,!1))}function x(u){c.isEmpty()?a=u:c.shift().reject(u),v()}function v(){q?.[Symbol.dispose](),K(),d=!0;const u=T(void 0,!0);for(;!c.isEmpty();)c.shift().resolve(u);return Promise.resolve(u)}},once=async function(t,e,n={}){const r=n?.signal;if(r?.aborted)throw new b(void 0,{cause:r?.reason});return new Promise((s,o)=>{const i=d=>{typeof t.removeListener=="function"&&t.removeListener(e,c),r!=null&&L(r,"abort",a),o(d)},c=(...d)=>{typeof t.removeListener=="function"&&t.removeListener("error",i),r!=null&&L(r,"abort",a),s(d)},f={__proto__:null,once:!0,[N]:!0};P(t,e,c,f),e!=="error"&&typeof t.once=="function"&&t.once("error",i);function a(){L(t,e,c),L(t,"error",i),o(new b(void 0,{cause:r?.reason}))}r!=null&&P(r,"abort",a,{__proto__:null,once:!0,[N]:!0})})},addAbortListener=function(t,e){if(t===void 0)throw new h("signal","AbortSignal",t);let n;return t.aborted?queueMicrotask(()=>e()):(t.addEventListener("abort",e,{__proto__:null,once:!0,[N]:!0}),n=()=>{t.removeEventListener("abort",e)}),{__proto__:null,[Symbol.dispose](){n?.()}}},getEventListeners=function(t,e){if(typeof t.listeners=="function")return t.listeners(e);if(H(t)){const n=t[kEvents].get(e),r=[];let s=n?.next;for(;s?.listener!==void 0;){const o=s.listener?.deref?s.listener.deref():s.listener;r.push(o),s=s.next}return r}throw new h("emitter",["EventEmitter","EventTarget"],t)},getMaxListeners=function(t){if(typeof t?.getMaxListeners=="function")return S(t);if(t?.[w])return t[w];throw new h("emitter",["EventEmitter","EventTarget"],t)},D=2048,M=D-1;class B{bottom;top;list;next;constructor(){this.bottom=0,this.top=0,this.list=new Array(D),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&M)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&M}shift(){const e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&M,e)}}class ${head;tail;constructor(){this.head=this.tail=new B}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new B),this.head.push(e)}shift(){const e=this.tail,n=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next,e.next=null),n}}function H(t){return typeof t?.addEventListener=="function"}function O(t,e,n,r){if(t[l])try{const s=e.then;typeof s=="function"&&s.call(e,void 0,function(o){process.nextTick(re,t,o,n,r)})}catch(s){t.emit("error",s)}}function re(t,e,n,r){if(typeof t[R]=="function")t[R](e,n,...r);else{const s=t[l];try{t[l]=!1,t.emit("error",e)}finally{t[l]=s}}}function S(t){return t._maxListeners===void 0?y:t._maxListeners}function se(t,e){let n="";try{const{name:o}=this.constructor;o!=="EventEmitter"&&(n=` on ${o} instance`)}catch{}const r=`
Emitted 'error' event${n} at:
`,s=(e.stack||"").split(`
`).slice(1);return t.stack+r+s.join(`
`)}function z(t,e,n,r){let s,o,i;if(o=t._events,o===void 0?(o=t._events={__proto__:null},t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener??n),o=t._events),i=o[e]),i===void 0)o[e]=n,++t._eventsCount;else if(typeof i=="function"?i=o[e]=r?[n,i]:[i,n]:r?i.unshift(n):i.push(n),s=S(t),s>0&&i.length>s&&!i.warned){i.warned=!0;const c=new Z(`Possible EventEmitter memory leak detected. ${i.length} ${String(e)} listeners added to ${F(t)}. MaxListeners is ${s}. Use emitter.setMaxListeners() to increase limit`,{name:"MaxListenersExceededWarning",emitter:t,type:e,count:i.length});process.emitWarning(c)}return t}function ie(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function U(t,e,n){const r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},s=ie.bind(r);return s.listener=n,r.wrapFn=s,s}function G(t,e,n){const r=t._events;if(r===void 0)return[];const s=r[e];return s===void 0?[]:typeof s=="function"?n?[s.listener||s]:[s]:n?oe(s):C(s)}function C(t){switch(t.length){case 2:return[t[0],t[1]];case 3:return[t[0],t[1],t[2]];case 4:return[t[0],t[1],t[2],t[3]];case 5:return[t[0],t[1],t[2],t[3],t[4]];case 6:return[t[0],t[1],t[2],t[3],t[4],t[5]]}return Array.prototype.slice(t)}function oe(t){const e=C(t);for(let n=0;n<e.length;++n){const r=e[n].listener;typeof r=="function"&&(e[n]=r)}return e}function T(t,e){return{value:t,done:e}}function L(t,e,n,r){if(typeof t.removeListener=="function")t.removeListener(e,n);else if(typeof t.removeEventListener=="function")t.removeEventListener(e,n,r);else throw new h("emitter","EventEmitter",t)}function P(t,e,n,r){if(typeof t.on=="function")r?.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,n,r);else throw new h("emitter","EventEmitter",t)}function ue(){const t=[];return{addEventListener(e,n,r,s){P(e,n,r,s),Array.prototype.push(t,[e,n,r,s])},removeAll(){for(;t.length>0;)Reflect.apply(L,void 0,t.pop())}}}function ce(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}exports.EventEmitter=EventEmitter;
import nodeEvents, { EventEmitter as EventEmitter$1 } from 'node:events';
declare const kCapture: unique symbol;
declare const kShapeMode: unique symbol;
type Listener = (...args: any[]) => void;
declare class EventEmitter implements EventEmitter$1 {
_events: any;
_eventsCount: number;
_maxListeners: number | undefined;
[kCapture]: boolean;
[kShapeMode]: boolean;
static captureRejectionSymbol: symbol;
static errorMonitor: symbol;
static kMaxEventTargetListeners: symbol;
static kMaxEventTargetListenersWarned: symbol;
static usingDomains: boolean;
static get on(): typeof nodeEvents.on;
static get once(): typeof nodeEvents.once;
static get getEventListeners(): typeof nodeEvents.getEventListeners;
static get getMaxListeners(): typeof nodeEvents.getMaxListeners;
static get addAbortListener(): typeof nodeEvents.addAbortListener;
static get EventEmitterAsyncResource(): typeof EventEmitterAsyncResource;
static get EventEmitter(): typeof EventEmitter;
static setMaxListeners(n?: number, ...eventTargets: (EventEmitter | EventTarget)[]): void;
static listenerCount(emitter: EventEmitter$1, type: string): number | undefined;
static init(): void;
static get captureRejections(): any;
static set captureRejections(value: any);
static get defaultMaxListeners(): number;
static set defaultMaxListeners(arg: number);
constructor(opts?: any);
/**
* Increases the max listeners of the event emitter.
* @param {number} n
* @returns {EventEmitter}
*/
setMaxListeners(n: number): this;
/**
* Returns the current max listener value for the event emitter.
* @returns {number}
*/
getMaxListeners(): number;
/**
* Synchronously calls each of the listeners registered
* for the event.
* @param {...any} [args]
* @returns {boolean}
*/
emit(type: string | symbol, ...args: any[]): boolean;
/**
* Adds a listener to the event emitter.
* @returns {EventEmitter}
*/
addListener(type: string | symbol, listener: Listener): this;
on(type: string | symbol, listener: Listener): this;
/**
* Adds the `listener` function to the beginning of
* the listeners array.
*/
prependListener(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the event emitter.
*/
once(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the beginning of
* the listeners array.
*/
prependOnceListener(type: string | symbol, listener: Listener): this;
/**
* Removes the specified `listener` from the listeners array.
* @param {string | symbol} type
* @param {Function} listener
* @returns {EventEmitter}
*/
removeListener(type: string | symbol, listener: Listener): this;
off(type: string | symbol, listener: Listener): this;
/**
* Removes all listeners from the event emitter. (Only
* removes listeners for a specific event name if specified
* as `type`).
*/
removeAllListeners(type?: string | symbol): this;
/**
* Returns a copy of the array of listeners for the event name
* specified as `type`.
* @param {string | symbol} type
* @returns {Function[]}
*/
listeners(type: string | symbol): any[];
/**
* Returns a copy of the array of listeners and wrappers for
* the event name specified as `type`.
* @returns {Function[]}
*/
rawListeners(type: string | symbol): any[];
/**
* Returns an array listing the events for which
* the emitter has registered listeners.
* @returns {any[]}
*/
eventNames(): (string | symbol)[];
/**
* Returns the number of listeners listening to event name
*/
listenerCount(eventName: string | symbol, listener?: Listener): number;
}
declare class EventEmitterAsyncResource extends EventEmitter {
/**
* @param {{
* name?: string,
* triggerAsyncId?: number,
* requireManualDestroy?: boolean,
* }} [options]
*/
constructor(options: any);
/**
* @param {symbol,string} event
* @param {...any} args
* @returns {boolean}
*/
emit(event: string | symbol, ...args: any[]): boolean;
/**
* @returns {void}
*/
emitDestroy(): void;
/**
* @type {number}
*/
get asyncId(): any;
/**
* @type {number}
*/
get triggerAsyncId(): any;
/**
* @type {EventEmitterReferencingAsyncResource}
*/
get asyncResource(): any;
}
export { EventEmitter };
import nodeEvents, { EventEmitter as EventEmitter$1 } from 'node:events';
declare const kCapture: unique symbol;
declare const kShapeMode: unique symbol;
type Listener = (...args: any[]) => void;
declare class EventEmitter implements EventEmitter$1 {
_events: any;
_eventsCount: number;
_maxListeners: number | undefined;
[kCapture]: boolean;
[kShapeMode]: boolean;
static captureRejectionSymbol: symbol;
static errorMonitor: symbol;
static kMaxEventTargetListeners: symbol;
static kMaxEventTargetListenersWarned: symbol;
static usingDomains: boolean;
static get on(): typeof nodeEvents.on;
static get once(): typeof nodeEvents.once;
static get getEventListeners(): typeof nodeEvents.getEventListeners;
static get getMaxListeners(): typeof nodeEvents.getMaxListeners;
static get addAbortListener(): typeof nodeEvents.addAbortListener;
static get EventEmitterAsyncResource(): typeof EventEmitterAsyncResource;
static get EventEmitter(): typeof EventEmitter;
static setMaxListeners(n?: number, ...eventTargets: (EventEmitter | EventTarget)[]): void;
static listenerCount(emitter: EventEmitter$1, type: string): number | undefined;
static init(): void;
static get captureRejections(): any;
static set captureRejections(value: any);
static get defaultMaxListeners(): number;
static set defaultMaxListeners(arg: number);
constructor(opts?: any);
/**
* Increases the max listeners of the event emitter.
* @param {number} n
* @returns {EventEmitter}
*/
setMaxListeners(n: number): this;
/**
* Returns the current max listener value for the event emitter.
* @returns {number}
*/
getMaxListeners(): number;
/**
* Synchronously calls each of the listeners registered
* for the event.
* @param {...any} [args]
* @returns {boolean}
*/
emit(type: string | symbol, ...args: any[]): boolean;
/**
* Adds a listener to the event emitter.
* @returns {EventEmitter}
*/
addListener(type: string | symbol, listener: Listener): this;
on(type: string | symbol, listener: Listener): this;
/**
* Adds the `listener` function to the beginning of
* the listeners array.
*/
prependListener(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the event emitter.
*/
once(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the beginning of
* the listeners array.
*/
prependOnceListener(type: string | symbol, listener: Listener): this;
/**
* Removes the specified `listener` from the listeners array.
* @param {string | symbol} type
* @param {Function} listener
* @returns {EventEmitter}
*/
removeListener(type: string | symbol, listener: Listener): this;
off(type: string | symbol, listener: Listener): this;
/**
* Removes all listeners from the event emitter. (Only
* removes listeners for a specific event name if specified
* as `type`).
*/
removeAllListeners(type?: string | symbol): this;
/**
* Returns a copy of the array of listeners for the event name
* specified as `type`.
* @param {string | symbol} type
* @returns {Function[]}
*/
listeners(type: string | symbol): any[];
/**
* Returns a copy of the array of listeners and wrappers for
* the event name specified as `type`.
* @returns {Function[]}
*/
rawListeners(type: string | symbol): any[];
/**
* Returns an array listing the events for which
* the emitter has registered listeners.
* @returns {any[]}
*/
eventNames(): (string | symbol)[];
/**
* Returns the number of listeners listening to event name
*/
listenerCount(eventName: string | symbol, listener?: Listener): number;
}
declare class EventEmitterAsyncResource extends EventEmitter {
/**
* @param {{
* name?: string,
* triggerAsyncId?: number,
* requireManualDestroy?: boolean,
* }} [options]
*/
constructor(options: any);
/**
* @param {symbol,string} event
* @param {...any} args
* @returns {boolean}
*/
emit(event: string | symbol, ...args: any[]): boolean;
/**
* @returns {void}
*/
emitDestroy(): void;
/**
* @type {number}
*/
get asyncId(): any;
/**
* @type {number}
*/
get triggerAsyncId(): any;
/**
* @type {EventEmitterReferencingAsyncResource}
*/
get asyncResource(): any;
}
export { EventEmitter };
import nodeEvents, { EventEmitter as EventEmitter$1 } from 'node:events';
declare const kCapture: unique symbol;
declare const kShapeMode: unique symbol;
type Listener = (...args: any[]) => void;
declare class EventEmitter implements EventEmitter$1 {
_events: any;
_eventsCount: number;
_maxListeners: number | undefined;
[kCapture]: boolean;
[kShapeMode]: boolean;
static captureRejectionSymbol: symbol;
static errorMonitor: symbol;
static kMaxEventTargetListeners: symbol;
static kMaxEventTargetListenersWarned: symbol;
static usingDomains: boolean;
static get on(): typeof nodeEvents.on;
static get once(): typeof nodeEvents.once;
static get getEventListeners(): typeof nodeEvents.getEventListeners;
static get getMaxListeners(): typeof nodeEvents.getMaxListeners;
static get addAbortListener(): typeof nodeEvents.addAbortListener;
static get EventEmitterAsyncResource(): typeof EventEmitterAsyncResource;
static get EventEmitter(): typeof EventEmitter;
static setMaxListeners(n?: number, ...eventTargets: (EventEmitter | EventTarget)[]): void;
static listenerCount(emitter: EventEmitter$1, type: string): number | undefined;
static init(): void;
static get captureRejections(): any;
static set captureRejections(value: any);
static get defaultMaxListeners(): number;
static set defaultMaxListeners(arg: number);
constructor(opts?: any);
/**
* Increases the max listeners of the event emitter.
* @param {number} n
* @returns {EventEmitter}
*/
setMaxListeners(n: number): this;
/**
* Returns the current max listener value for the event emitter.
* @returns {number}
*/
getMaxListeners(): number;
/**
* Synchronously calls each of the listeners registered
* for the event.
* @param {...any} [args]
* @returns {boolean}
*/
emit(type: string | symbol, ...args: any[]): boolean;
/**
* Adds a listener to the event emitter.
* @returns {EventEmitter}
*/
addListener(type: string | symbol, listener: Listener): this;
on(type: string | symbol, listener: Listener): this;
/**
* Adds the `listener` function to the beginning of
* the listeners array.
*/
prependListener(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the event emitter.
*/
once(type: string | symbol, listener: Listener): this;
/**
* Adds a one-time `listener` function to the beginning of
* the listeners array.
*/
prependOnceListener(type: string | symbol, listener: Listener): this;
/**
* Removes the specified `listener` from the listeners array.
* @param {string | symbol} type
* @param {Function} listener
* @returns {EventEmitter}
*/
removeListener(type: string | symbol, listener: Listener): this;
off(type: string | symbol, listener: Listener): this;
/**
* Removes all listeners from the event emitter. (Only
* removes listeners for a specific event name if specified
* as `type`).
*/
removeAllListeners(type?: string | symbol): this;
/**
* Returns a copy of the array of listeners for the event name
* specified as `type`.
* @param {string | symbol} type
* @returns {Function[]}
*/
listeners(type: string | symbol): any[];
/**
* Returns a copy of the array of listeners and wrappers for
* the event name specified as `type`.
* @returns {Function[]}
*/
rawListeners(type: string | symbol): any[];
/**
* Returns an array listing the events for which
* the emitter has registered listeners.
* @returns {any[]}
*/
eventNames(): (string | symbol)[];
/**
* Returns the number of listeners listening to event name
*/
listenerCount(eventName: string | symbol, listener?: Listener): number;
}
declare class EventEmitterAsyncResource extends EventEmitter {
/**
* @param {{
* name?: string,
* triggerAsyncId?: number,
* requireManualDestroy?: boolean,
* }} [options]
*/
constructor(options: any);
/**
* @param {symbol,string} event
* @param {...any} args
* @returns {boolean}
*/
emit(event: string | symbol, ...args: any[]): boolean;
/**
* @returns {void}
*/
emitDestroy(): void;
/**
* @type {number}
*/
get asyncId(): any;
/**
* @type {number}
*/
get triggerAsyncId(): any;
/**
* @type {EventEmitterReferencingAsyncResource}
*/
get asyncResource(): any;
}
export { EventEmitter };
let v=10;const Y=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),F=(t,e)=>t,_=Error,Z=Error,h=Error,w=Error,ee=Error,R=Symbol.for("nodejs.rejection"),a=Symbol.for("kCapture"),M=Symbol.for("events.errorMonitor"),g=Symbol.for("shapeMode"),b=Symbol.for("events.maxEventTargetListeners"),te=Symbol.for("kEnhanceStackBeforeInspector"),ne=Symbol.for("nodejs.watermarkData"),d=Symbol.for("kAsyncResource"),re=Symbol.for("kFirstEventParam"),S=Symbol.for("kResistStopPropagation"),W=Symbol.for("events.maxEventTargetListenersWarned");class m{_events=void 0;_eventsCount=0;_maxListeners=v;[a]=!1;[g]=!1;static captureRejectionSymbol=R;static errorMonitor=M;static kMaxEventTargetListeners=b;static kMaxEventTargetListenersWarned=W;static usingDomains=!1;static get on(){return ie}static get once(){return oe}static get getEventListeners(){return ue}static get getMaxListeners(){return ce}static get addAbortListener(){return $}static get EventEmitterAsyncResource(){return se}static get EventEmitter(){return m}static setMaxListeners(e=v,...n){if(n.length===0)v=e;else for(const r of n)if(q(r))r[b]=e,r[W]=!1;else if(typeof r.setMaxListeners=="function")r.setMaxListeners(e);else throw new h("eventTargets",["EventEmitter","EventTarget"],r)}static listenerCount(e,n){if(typeof e.listenerCount=="function")return e.listenerCount(n);m.prototype.listenerCount.call(e,n)}static init(){throw new Error("EventEmitter.init() is not implemented.")}static get captureRejections(){return this[a]}static set captureRejections(e){this[a]=e}static get defaultMaxListeners(){return v}static set defaultMaxListeners(e){v=e}constructor(e){this._events===void 0||this._events===Object.getPrototypeOf(this)._events?(this._events={__proto__:null},this._eventsCount=0,this[g]=!1):this[g]=!0,this._maxListeners=this._maxListeners||void 0,e?.captureRejections?this[a]=!!e.captureRejections:this[a]=m.prototype[a]}setMaxListeners(e){return this._maxListeners=e,this}getMaxListeners(){return j(this)}emit(e,...n){let r=e==="error";const s=this._events;if(s!==void 0)r&&s[M]!==void 0&&this.emit(M,...n),r=r&&s.error===void 0;else if(!r)return!1;if(r){let i;if(n.length>0&&(i=n[0]),i instanceof Error){try{const l={};Error.captureStackTrace?.(l,m.prototype.emit),Object.defineProperty(i,te,{__proto__:null,value:Function.prototype.bind(le,this,i,l),configurable:!0})}catch{}throw i}let c;try{c=F(i)}catch{c=i}const f=new Z(c);throw f.context=i,f}const o=s[e];if(o===void 0)return!1;if(typeof o=="function"){const i=o.apply(this,n);i!=null&&z(this,i,e,n)}else{const i=o.length,c=C(o);for(let f=0;f<i;++f){const l=c[f].apply(this,n);l!=null&&z(this,l,e,n)}}return!0}addListener(e,n){return B(this,e,n,!1),this}on(e,n){return this.addListener(e,n)}prependListener(e,n){return B(this,e,n,!0),this}once(e,n){return this.on(e,G(this,e,n)),this}prependOnceListener(e,n){return this.prependListener(e,G(this,e,n)),this}removeListener(e,n){const r=this._events;if(r===void 0)return this;const s=r[e];if(s===void 0)return this;if(s===n||s.listener===n)this._eventsCount-=1,this[g]?r[e]=void 0:this._eventsCount===0?this._events={__proto__:null}:(delete r[e],r.removeListener&&this.emit("removeListener",e,s.listener||n));else if(typeof s!="function"){let o=-1;for(let i=s.length-1;i>=0;i--)if(s[i]===n||s[i].listener===n){o=i;break}if(o<0)return this;o===0?s.shift():me(s,o),s.length===1&&(r[e]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",e,n)}return this}off(e,n){return this.removeListener(e,n)}removeAllListeners(e){const n=this._events;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events={__proto__:null},this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events={__proto__:null}:delete n[e]),this[g]=!1,this;if(arguments.length===0){for(const s of Reflect.ownKeys(n))s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events={__proto__:null},this._eventsCount=0,this[g]=!1,this}const r=n[e];if(typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(let s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this}listeners(e){return U(this,e,!0)}rawListeners(e){return U(this,e,!1)}eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}listenerCount(e,n){const r=this._events;if(r!==void 0){const s=r[e];if(typeof s=="function")return n!=null?n===s||n===s.listener?1:0:1;if(s!==void 0){if(n!=null){let o=0;for(let i=0,c=s.length;i<c;i++)(s[i]===n||s[i].listener===n)&&o++;return o}return s.length}}return 0}}class se extends m{constructor(e){let n;typeof e=="string"?(n=e,e=void 0):n=e?.name||new.target.name,super(e),this[d]=new EventEmitterReferencingAsyncResource(this,n,e)}emit(e,...n){if(this[d]===void 0)throw new _("EventEmitterAsyncResource");const{asyncResource:r}=this;return Array.prototype.unshift(n,super.emit,this,e),Reflect.apply(r.runInAsyncScope,r,n)}emitDestroy(){if(this[d]===void 0)throw new _("EventEmitterAsyncResource");this.asyncResource.emitDestroy()}get asyncId(){if(this[d]===void 0)throw new _("EventEmitterAsyncResource");return this.asyncResource.asyncId()}get triggerAsyncId(){if(this[d]===void 0)throw new _("EventEmitterAsyncResource");return this.asyncResource.triggerAsyncId()}get asyncResource(){if(this[d]===void 0)throw new _("EventEmitterAsyncResource");return this[d]}}const ie=function(t,e,n={}){const r=n.signal;if(r?.aborted)throw new w(void 0,{cause:r?.reason});const s=n.highWaterMark??n.highWatermark??Number.MAX_SAFE_INTEGER,o=n.lowWaterMark??n.lowWatermark??1,i=new K,c=new K;let f=!1,l=null,p=!1,y=0;const H=Object.setPrototypeOf({next(){if(y){const u=i.shift();return y--,f&&y<o&&(t.resume?.(),f=!1),Promise.resolve(P(u,!1))}if(l){const u=Promise.reject(l);return l=null,u}return p?L():new Promise(function(u,X){c.push({resolve:u,reject:X})})},return(){return L()},throw(u){if(!u||!(u instanceof Error))throw new h("EventEmitter.AsyncIterator","Error",u);A(u)},[Symbol.asyncIterator](){return this},[ne]:{get size(){return y},get low(){return o},get high(){return s},get isPaused(){return f}}},Y),{addEventListener:x,removeAll:J}=de();x(t,e,n[re]?I:function(...u){return I(u)}),e!=="error"&&typeof t.on=="function"&&x(t,"error",A);const O=n?.close;if(O?.length)for(const u of O)x(t,u,L);const Q=r?$(r,V):null;return H;function V(){A(new w(void 0,{cause:r?.reason}))}function I(u){c.isEmpty()?(y++,!f&&y>s&&(f=!0,t.pause?.()),i.push(u)):c.shift().resolve(P(u,!1))}function A(u){c.isEmpty()?l=u:c.shift().reject(u),L()}function L(){Q?.[Symbol.dispose](),J(),p=!0;const u=P(void 0,!0);for(;!c.isEmpty();)c.shift().resolve(u);return Promise.resolve(u)}},oe=async function(t,e,n={}){const r=n?.signal;if(r?.aborted)throw new w(void 0,{cause:r?.reason});return new Promise((s,o)=>{const i=p=>{typeof t.removeListener=="function"&&t.removeListener(e,c),r!=null&&E(r,"abort",l),o(p)},c=(...p)=>{typeof t.removeListener=="function"&&t.removeListener("error",i),r!=null&&E(r,"abort",l),s(p)},f={__proto__:null,once:!0,[S]:!0};T(t,e,c,f),e!=="error"&&typeof t.once=="function"&&t.once("error",i);function l(){E(t,e,c),E(t,"error",i),o(new w(void 0,{cause:r?.reason}))}r!=null&&T(r,"abort",l,{__proto__:null,once:!0,[S]:!0})})},$=function(t,e){if(t===void 0)throw new h("signal","AbortSignal",t);let n;return t.aborted?queueMicrotask(()=>e()):(t.addEventListener("abort",e,{__proto__:null,once:!0,[S]:!0}),n=()=>{t.removeEventListener("abort",e)}),{__proto__:null,[Symbol.dispose](){n?.()}}},ue=function(t,e){if(typeof t.listeners=="function")return t.listeners(e);if(q(t)){const n=t[kEvents].get(e),r=[];let s=n?.next;for(;s?.listener!==void 0;){const o=s.listener?.deref?s.listener.deref():s.listener;r.push(o),s=s.next}return r}throw new h("emitter",["EventEmitter","EventTarget"],t)},ce=function(t){if(typeof t?.getMaxListeners=="function")return j(t);if(t?.[b])return t[b];throw new h("emitter",["EventEmitter","EventTarget"],t)},D=2048,k=D-1;class N{bottom;top;list;next;constructor(){this.bottom=0,this.top=0,this.list=new Array(D),this.next=null}isEmpty(){return this.top===this.bottom}isFull(){return(this.top+1&k)===this.bottom}push(e){this.list[this.top]=e,this.top=this.top+1&k}shift(){const e=this.list[this.bottom];return e===void 0?null:(this.list[this.bottom]=void 0,this.bottom=this.bottom+1&k,e)}}class K{head;tail;constructor(){this.head=this.tail=new N}isEmpty(){return this.head.isEmpty()}push(e){this.head.isFull()&&(this.head=this.head.next=new N),this.head.push(e)}shift(){const e=this.tail,n=e.shift();return e.isEmpty()&&e.next!==null&&(this.tail=e.next,e.next=null),n}}function q(t){return typeof t?.addEventListener=="function"}function z(t,e,n,r){if(t[a])try{const s=e.then;typeof s=="function"&&s.call(e,void 0,function(o){process.nextTick(fe,t,o,n,r)})}catch(s){t.emit("error",s)}}function fe(t,e,n,r){if(typeof t[R]=="function")t[R](e,n,...r);else{const s=t[a];try{t[a]=!1,t.emit("error",e)}finally{t[a]=s}}}function j(t){return t._maxListeners===void 0?v:t._maxListeners}function le(t,e){let n="";try{const{name:o}=this.constructor;o!=="EventEmitter"&&(n=` on ${o} instance`)}catch{}const r=`
Emitted 'error' event${n} at:
`,s=(e.stack||"").split(`
`).slice(1);return t.stack+r+s.join(`
`)}function B(t,e,n,r){let s,o,i;if(o=t._events,o===void 0?(o=t._events={__proto__:null},t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener??n),o=t._events),i=o[e]),i===void 0)o[e]=n,++t._eventsCount;else if(typeof i=="function"?i=o[e]=r?[n,i]:[i,n]:r?i.unshift(n):i.push(n),s=j(t),s>0&&i.length>s&&!i.warned){i.warned=!0;const c=new ee(`Possible EventEmitter memory leak detected. ${i.length} ${String(e)} listeners added to ${F(t)}. MaxListeners is ${s}. Use emitter.setMaxListeners() to increase limit`,{name:"MaxListenersExceededWarning",emitter:t,type:e,count:i.length});process.emitWarning(c)}return t}function ae(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function G(t,e,n){const r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},s=ae.bind(r);return s.listener=n,r.wrapFn=s,s}function U(t,e,n){const r=t._events;if(r===void 0)return[];const s=r[e];return s===void 0?[]:typeof s=="function"?n?[s.listener||s]:[s]:n?he(s):C(s)}function C(t){switch(t.length){case 2:return[t[0],t[1]];case 3:return[t[0],t[1],t[2]];case 4:return[t[0],t[1],t[2],t[3]];case 5:return[t[0],t[1],t[2],t[3],t[4]];case 6:return[t[0],t[1],t[2],t[3],t[4],t[5]]}return Array.prototype.slice(t)}function he(t){const e=C(t);for(let n=0;n<e.length;++n){const r=e[n].listener;typeof r=="function"&&(e[n]=r)}return e}function P(t,e){return{value:t,done:e}}function E(t,e,n,r){if(typeof t.removeListener=="function")t.removeListener(e,n);else if(typeof t.removeEventListener=="function")t.removeEventListener(e,n,r);else throw new h("emitter","EventEmitter",t)}function T(t,e,n,r){if(typeof t.on=="function")r?.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,n,r);else throw new h("emitter","EventEmitter",t)}function de(){const t=[];return{addEventListener(e,n,r,s){T(e,n,r,s),Array.prototype.push(t,[e,n,r,s])},removeAll(){for(;t.length>0;)Reflect.apply(E,void 0,t.pop())}}}function me(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}export{m as EventEmitter};
"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;
import NodeHTTP from 'node:http';
import * as NodeNet from 'node:net';
import { Socket as Socket$1 } from 'node:net';
import * as NodeStream from 'node:stream';
import { EventEmitter } from 'node-mock-http/_polyfill/events';
type Callback<E = Error | null | undefined> = (error?: E) => void;
type BufferEncoding = any;
type DuplexClass = new () => NodeStream.Duplex;
declare const Duplex: DuplexClass;
declare class Socket extends Duplex implements NodeNet.Socket {
__unenv__: {};
readonly bufferSize: number;
readonly bytesRead: number;
readonly bytesWritten: number;
readonly connecting: boolean;
readonly destroyed: boolean;
readonly pending: boolean;
readonly localAddress: string;
readonly localPort: number;
readonly remoteAddress?: string;
readonly remoteFamily?: string;
readonly remotePort?: number;
readonly autoSelectFamilyAttemptedAddresses: never[];
readonly readyState: NodeNet.SocketReadyState;
constructor(_options?: NodeNet.SocketConstructorOpts);
write(_buffer: Uint8Array | string, _arg1?: BufferEncoding | Callback<Error | undefined>, _arg2?: Callback<Error | undefined>): boolean;
connect(_arg1: number | string | NodeNet.SocketConnectOpts, _arg2?: string | Callback, _arg3?: Callback): this;
end(_arg1?: Callback | Uint8Array | string, _arg2?: BufferEncoding | Callback, _arg3?: Callback): this;
setEncoding(_encoding?: BufferEncoding): this;
pause(): this;
resume(): this;
setTimeout(_timeout: number, _callback?: Callback): this;
setNoDelay(_noDelay?: boolean): this;
setKeepAlive(_enable?: boolean, _initialDelay?: number): this;
address(): {};
unref(): this;
ref(): this;
destroySoon(): void;
resetAndDestroy(): this;
}
declare class Readable extends EventEmitter implements NodeStream.Readable {
__unenv__: {};
readonly readableEncoding: BufferEncoding | null;
readonly readableEnded: boolean;
readonly readableFlowing: boolean | null;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;
readonly readableAborted: boolean;
readonly readableDidRead: boolean;
readonly closed: boolean;
readonly errored: Error | null;
readable: boolean;
destroyed: boolean;
static from(_iterable: Iterable<any> | AsyncIterable<any>, options?: NodeStream.ReadableOptions): Readable;
constructor(_opts?: NodeStream.ReadableOptions);
_read(_size: number): void;
read(_size?: number): void;
setEncoding(_encoding: BufferEncoding): this;
pause(): this;
resume(): this;
isPaused(): boolean;
unpipe(_destination?: any): this;
unshift(_chunk: any, _encoding?: BufferEncoding): void;
wrap(_oldStream: any): this;
push(_chunk: any, _encoding?: BufferEncoding): boolean;
_destroy(_error?: any, _callback?: Callback<any>): void;
destroy(error?: Error): this;
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
[Symbol.asyncDispose](): Promise<void>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
iterator(_options?: {
destroyOnReturn?: boolean | undefined;
} | undefined): NodeJS.AsyncIterator<any>;
map(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
filter(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): NodeStream.Readable;
forEach(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => void | Promise<void>, _options?: ArrayOptions | undefined): Promise<void>;
reduce(_fn: (accumulator: any, data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _initialValue?: any, _options?: ArrayOptions | undefined): Promise<any>;
find(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<any>;
findIndex(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<number>;
some(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<boolean>;
toArray(_options?: Pick<ArrayOptions, "signal"> | undefined): Promise<any[]>;
every(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean | Promise<boolean>, _options?: ArrayOptions | undefined): Promise<boolean>;
flatMap(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
drop(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
take(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
asIndexedPairs(_options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
}
interface ArrayOptions {
concurrency?: number;
signal?: AbortSignal;
}
declare class IncomingMessage extends Readable implements NodeHTTP.IncomingMessage {
aborted: boolean;
httpVersion: string;
httpVersionMajor: number;
httpVersionMinor: number;
complete: boolean;
connection: Socket;
socket: Socket;
headers: NodeHTTP.IncomingHttpHeaders;
trailers: {};
method: string;
url: string;
statusCode: number;
statusMessage: string;
closed: boolean;
errored: Error | null;
readable: boolean;
constructor(socket?: Socket);
get rawHeaders(): any[];
get rawTrailers(): never[];
setTimeout(_msecs: number, _callback?: () => void): this;
get headersDistinct(): Record<string, string[]>;
get trailersDistinct(): Record<string, string[]>;
}
declare class Writable extends EventEmitter implements NodeStream.Writable {
__unenv__: {};
readonly writable: boolean;
writableEnded: boolean;
writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
readonly writableCorked: number;
readonly closed: boolean;
readonly errored: Error | null;
readonly writableNeedDrain: boolean;
destroyed: boolean;
_data: unknown;
_encoding: BufferEncoding;
constructor(_opts?: NodeStream.WritableOptions);
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
_write(chunk: any, encoding: BufferEncoding, callback?: Callback): void;
_writev?(_chunks: Array<{
chunk: any;
encoding: BufferEncoding;
}>, _callback: (error?: Error | null) => void): void;
_destroy(_error: any, _callback: Callback<any>): void;
_final(_callback: Callback): void;
write(chunk: any, arg2?: BufferEncoding | Callback, arg3?: Callback): boolean;
setDefaultEncoding(_encoding: BufferEncoding): this;
end(arg1: Callback | any, arg2?: Callback | BufferEncoding, arg3?: Callback): this;
cork(): void;
uncork(): void;
destroy(_error?: Error): this;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
}
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse {
statusCode: number;
statusMessage: string;
upgrading: boolean;
chunkedEncoding: boolean;
shouldKeepAlive: boolean;
useChunkedEncodingByDefault: boolean;
sendDate: boolean;
finished: boolean;
headersSent: boolean;
strictContentLength: boolean;
connection: Socket$1 | null;
socket: Socket$1 | null;
req: NodeHTTP.IncomingMessage;
_headers: Record<string, number | string | string[] | undefined>;
constructor(req: NodeHTTP.IncomingMessage);
assignSocket(socket: Socket$1): void;
_flush(): void;
detachSocket(_socket: Socket$1): void;
writeContinue(_callback?: Callback): void;
writeHead(statusCode: number, arg1?: string | NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[], arg2?: NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[]): this;
writeProcessing(): void;
setTimeout(_msecs: number, _callback?: Callback): this;
appendHeader(name: string, value: string | string[]): this;
setHeader(name: string, value: number | string | string[]): this;
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
getHeader(name: string): number | string | string[] | undefined;
getHeaders(): NodeHTTP.OutgoingHttpHeaders;
getHeaderNames(): string[];
hasHeader(name: string): boolean;
removeHeader(name: string): void;
addTrailers(_headers: NodeHTTP.OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
flushHeaders(): void;
writeEarlyHints(_headers: NodeHTTP.OutgoingHttpHeaders, cb: () => void): void;
}
type MaybePromise<T> = T | Promise<T>;
type NodeRequestHandler = (req: IncomingMessage, res: ServerResponse) => MaybePromise<void | unknown>;
type NodeRequestHeaders = Record<string, string | string[]>;
type NodeResponseHeaders = Record<string, string | undefined | number | string[]>;
type AbstractRequest = {
[key: string]: any;
url?: URL | string;
method?: string;
headers?: HeadersInit | NodeRequestHeaders;
protocol?: string;
body?: any;
};
type AbstractResponse = {
body: any;
headers: NodeResponseHeaders;
status: number;
statusText: string;
};
declare function callNodeRequestHandler(handler: NodeRequestHandler, aRequest: AbstractRequest): Promise<AbstractResponse>;
declare function fetchNodeRequestHandler(handler: NodeRequestHandler, url: string | URL, init?: RequestInit): Promise<Response>;
export { type AbstractRequest, type AbstractResponse, IncomingMessage, type NodeRequestHandler, type NodeRequestHeaders, type NodeResponseHeaders, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
import NodeHTTP from 'node:http';
import * as NodeNet from 'node:net';
import { Socket as Socket$1 } from 'node:net';
import * as NodeStream from 'node:stream';
import { EventEmitter } from 'node-mock-http/_polyfill/events';
type Callback<E = Error | null | undefined> = (error?: E) => void;
type BufferEncoding = any;
type DuplexClass = new () => NodeStream.Duplex;
declare const Duplex: DuplexClass;
declare class Socket extends Duplex implements NodeNet.Socket {
__unenv__: {};
readonly bufferSize: number;
readonly bytesRead: number;
readonly bytesWritten: number;
readonly connecting: boolean;
readonly destroyed: boolean;
readonly pending: boolean;
readonly localAddress: string;
readonly localPort: number;
readonly remoteAddress?: string;
readonly remoteFamily?: string;
readonly remotePort?: number;
readonly autoSelectFamilyAttemptedAddresses: never[];
readonly readyState: NodeNet.SocketReadyState;
constructor(_options?: NodeNet.SocketConstructorOpts);
write(_buffer: Uint8Array | string, _arg1?: BufferEncoding | Callback<Error | undefined>, _arg2?: Callback<Error | undefined>): boolean;
connect(_arg1: number | string | NodeNet.SocketConnectOpts, _arg2?: string | Callback, _arg3?: Callback): this;
end(_arg1?: Callback | Uint8Array | string, _arg2?: BufferEncoding | Callback, _arg3?: Callback): this;
setEncoding(_encoding?: BufferEncoding): this;
pause(): this;
resume(): this;
setTimeout(_timeout: number, _callback?: Callback): this;
setNoDelay(_noDelay?: boolean): this;
setKeepAlive(_enable?: boolean, _initialDelay?: number): this;
address(): {};
unref(): this;
ref(): this;
destroySoon(): void;
resetAndDestroy(): this;
}
declare class Readable extends EventEmitter implements NodeStream.Readable {
__unenv__: {};
readonly readableEncoding: BufferEncoding | null;
readonly readableEnded: boolean;
readonly readableFlowing: boolean | null;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;
readonly readableAborted: boolean;
readonly readableDidRead: boolean;
readonly closed: boolean;
readonly errored: Error | null;
readable: boolean;
destroyed: boolean;
static from(_iterable: Iterable<any> | AsyncIterable<any>, options?: NodeStream.ReadableOptions): Readable;
constructor(_opts?: NodeStream.ReadableOptions);
_read(_size: number): void;
read(_size?: number): void;
setEncoding(_encoding: BufferEncoding): this;
pause(): this;
resume(): this;
isPaused(): boolean;
unpipe(_destination?: any): this;
unshift(_chunk: any, _encoding?: BufferEncoding): void;
wrap(_oldStream: any): this;
push(_chunk: any, _encoding?: BufferEncoding): boolean;
_destroy(_error?: any, _callback?: Callback<any>): void;
destroy(error?: Error): this;
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
[Symbol.asyncDispose](): Promise<void>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
iterator(_options?: {
destroyOnReturn?: boolean | undefined;
} | undefined): NodeJS.AsyncIterator<any>;
map(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
filter(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): NodeStream.Readable;
forEach(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => void | Promise<void>, _options?: ArrayOptions | undefined): Promise<void>;
reduce(_fn: (accumulator: any, data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _initialValue?: any, _options?: ArrayOptions | undefined): Promise<any>;
find(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<any>;
findIndex(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<number>;
some(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<boolean>;
toArray(_options?: Pick<ArrayOptions, "signal"> | undefined): Promise<any[]>;
every(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean | Promise<boolean>, _options?: ArrayOptions | undefined): Promise<boolean>;
flatMap(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
drop(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
take(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
asIndexedPairs(_options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
}
interface ArrayOptions {
concurrency?: number;
signal?: AbortSignal;
}
declare class IncomingMessage extends Readable implements NodeHTTP.IncomingMessage {
aborted: boolean;
httpVersion: string;
httpVersionMajor: number;
httpVersionMinor: number;
complete: boolean;
connection: Socket;
socket: Socket;
headers: NodeHTTP.IncomingHttpHeaders;
trailers: {};
method: string;
url: string;
statusCode: number;
statusMessage: string;
closed: boolean;
errored: Error | null;
readable: boolean;
constructor(socket?: Socket);
get rawHeaders(): any[];
get rawTrailers(): never[];
setTimeout(_msecs: number, _callback?: () => void): this;
get headersDistinct(): Record<string, string[]>;
get trailersDistinct(): Record<string, string[]>;
}
declare class Writable extends EventEmitter implements NodeStream.Writable {
__unenv__: {};
readonly writable: boolean;
writableEnded: boolean;
writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
readonly writableCorked: number;
readonly closed: boolean;
readonly errored: Error | null;
readonly writableNeedDrain: boolean;
destroyed: boolean;
_data: unknown;
_encoding: BufferEncoding;
constructor(_opts?: NodeStream.WritableOptions);
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
_write(chunk: any, encoding: BufferEncoding, callback?: Callback): void;
_writev?(_chunks: Array<{
chunk: any;
encoding: BufferEncoding;
}>, _callback: (error?: Error | null) => void): void;
_destroy(_error: any, _callback: Callback<any>): void;
_final(_callback: Callback): void;
write(chunk: any, arg2?: BufferEncoding | Callback, arg3?: Callback): boolean;
setDefaultEncoding(_encoding: BufferEncoding): this;
end(arg1: Callback | any, arg2?: Callback | BufferEncoding, arg3?: Callback): this;
cork(): void;
uncork(): void;
destroy(_error?: Error): this;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
}
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse {
statusCode: number;
statusMessage: string;
upgrading: boolean;
chunkedEncoding: boolean;
shouldKeepAlive: boolean;
useChunkedEncodingByDefault: boolean;
sendDate: boolean;
finished: boolean;
headersSent: boolean;
strictContentLength: boolean;
connection: Socket$1 | null;
socket: Socket$1 | null;
req: NodeHTTP.IncomingMessage;
_headers: Record<string, number | string | string[] | undefined>;
constructor(req: NodeHTTP.IncomingMessage);
assignSocket(socket: Socket$1): void;
_flush(): void;
detachSocket(_socket: Socket$1): void;
writeContinue(_callback?: Callback): void;
writeHead(statusCode: number, arg1?: string | NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[], arg2?: NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[]): this;
writeProcessing(): void;
setTimeout(_msecs: number, _callback?: Callback): this;
appendHeader(name: string, value: string | string[]): this;
setHeader(name: string, value: number | string | string[]): this;
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
getHeader(name: string): number | string | string[] | undefined;
getHeaders(): NodeHTTP.OutgoingHttpHeaders;
getHeaderNames(): string[];
hasHeader(name: string): boolean;
removeHeader(name: string): void;
addTrailers(_headers: NodeHTTP.OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
flushHeaders(): void;
writeEarlyHints(_headers: NodeHTTP.OutgoingHttpHeaders, cb: () => void): void;
}
type MaybePromise<T> = T | Promise<T>;
type NodeRequestHandler = (req: IncomingMessage, res: ServerResponse) => MaybePromise<void | unknown>;
type NodeRequestHeaders = Record<string, string | string[]>;
type NodeResponseHeaders = Record<string, string | undefined | number | string[]>;
type AbstractRequest = {
[key: string]: any;
url?: URL | string;
method?: string;
headers?: HeadersInit | NodeRequestHeaders;
protocol?: string;
body?: any;
};
type AbstractResponse = {
body: any;
headers: NodeResponseHeaders;
status: number;
statusText: string;
};
declare function callNodeRequestHandler(handler: NodeRequestHandler, aRequest: AbstractRequest): Promise<AbstractResponse>;
declare function fetchNodeRequestHandler(handler: NodeRequestHandler, url: string | URL, init?: RequestInit): Promise<Response>;
export { type AbstractRequest, type AbstractResponse, IncomingMessage, type NodeRequestHandler, type NodeRequestHeaders, type NodeResponseHeaders, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
import NodeHTTP from 'node:http';
import * as NodeNet from 'node:net';
import { Socket as Socket$1 } from 'node:net';
import * as NodeStream from 'node:stream';
import { EventEmitter } from 'node-mock-http/_polyfill/events';
type Callback<E = Error | null | undefined> = (error?: E) => void;
type BufferEncoding = any;
type DuplexClass = new () => NodeStream.Duplex;
declare const Duplex: DuplexClass;
declare class Socket extends Duplex implements NodeNet.Socket {
__unenv__: {};
readonly bufferSize: number;
readonly bytesRead: number;
readonly bytesWritten: number;
readonly connecting: boolean;
readonly destroyed: boolean;
readonly pending: boolean;
readonly localAddress: string;
readonly localPort: number;
readonly remoteAddress?: string;
readonly remoteFamily?: string;
readonly remotePort?: number;
readonly autoSelectFamilyAttemptedAddresses: never[];
readonly readyState: NodeNet.SocketReadyState;
constructor(_options?: NodeNet.SocketConstructorOpts);
write(_buffer: Uint8Array | string, _arg1?: BufferEncoding | Callback<Error | undefined>, _arg2?: Callback<Error | undefined>): boolean;
connect(_arg1: number | string | NodeNet.SocketConnectOpts, _arg2?: string | Callback, _arg3?: Callback): this;
end(_arg1?: Callback | Uint8Array | string, _arg2?: BufferEncoding | Callback, _arg3?: Callback): this;
setEncoding(_encoding?: BufferEncoding): this;
pause(): this;
resume(): this;
setTimeout(_timeout: number, _callback?: Callback): this;
setNoDelay(_noDelay?: boolean): this;
setKeepAlive(_enable?: boolean, _initialDelay?: number): this;
address(): {};
unref(): this;
ref(): this;
destroySoon(): void;
resetAndDestroy(): this;
}
declare class Readable extends EventEmitter implements NodeStream.Readable {
__unenv__: {};
readonly readableEncoding: BufferEncoding | null;
readonly readableEnded: boolean;
readonly readableFlowing: boolean | null;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;
readonly readableAborted: boolean;
readonly readableDidRead: boolean;
readonly closed: boolean;
readonly errored: Error | null;
readable: boolean;
destroyed: boolean;
static from(_iterable: Iterable<any> | AsyncIterable<any>, options?: NodeStream.ReadableOptions): Readable;
constructor(_opts?: NodeStream.ReadableOptions);
_read(_size: number): void;
read(_size?: number): void;
setEncoding(_encoding: BufferEncoding): this;
pause(): this;
resume(): this;
isPaused(): boolean;
unpipe(_destination?: any): this;
unshift(_chunk: any, _encoding?: BufferEncoding): void;
wrap(_oldStream: any): this;
push(_chunk: any, _encoding?: BufferEncoding): boolean;
_destroy(_error?: any, _callback?: Callback<any>): void;
destroy(error?: Error): this;
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
[Symbol.asyncDispose](): Promise<void>;
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
iterator(_options?: {
destroyOnReturn?: boolean | undefined;
} | undefined): NodeJS.AsyncIterator<any>;
map(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
filter(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): NodeStream.Readable;
forEach(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => void | Promise<void>, _options?: ArrayOptions | undefined): Promise<void>;
reduce(_fn: (accumulator: any, data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _initialValue?: any, _options?: ArrayOptions | undefined): Promise<any>;
find(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<any>;
findIndex(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<number>;
some(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean, _options?: ArrayOptions | undefined): Promise<boolean>;
toArray(_options?: Pick<ArrayOptions, "signal"> | undefined): Promise<any[]>;
every(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => boolean | Promise<boolean>, _options?: ArrayOptions | undefined): Promise<boolean>;
flatMap(_fn: (data: any, options?: Pick<ArrayOptions, "signal"> | undefined) => any, _options?: ArrayOptions | undefined): NodeStream.Readable;
drop(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
take(_limit: number, _options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
asIndexedPairs(_options?: Pick<ArrayOptions, "signal"> | undefined): NodeStream.Readable;
}
interface ArrayOptions {
concurrency?: number;
signal?: AbortSignal;
}
declare class IncomingMessage extends Readable implements NodeHTTP.IncomingMessage {
aborted: boolean;
httpVersion: string;
httpVersionMajor: number;
httpVersionMinor: number;
complete: boolean;
connection: Socket;
socket: Socket;
headers: NodeHTTP.IncomingHttpHeaders;
trailers: {};
method: string;
url: string;
statusCode: number;
statusMessage: string;
closed: boolean;
errored: Error | null;
readable: boolean;
constructor(socket?: Socket);
get rawHeaders(): any[];
get rawTrailers(): never[];
setTimeout(_msecs: number, _callback?: () => void): this;
get headersDistinct(): Record<string, string[]>;
get trailersDistinct(): Record<string, string[]>;
}
declare class Writable extends EventEmitter implements NodeStream.Writable {
__unenv__: {};
readonly writable: boolean;
writableEnded: boolean;
writableFinished: boolean;
readonly writableHighWaterMark: number;
readonly writableLength: number;
readonly writableObjectMode: boolean;
readonly writableCorked: number;
readonly closed: boolean;
readonly errored: Error | null;
readonly writableNeedDrain: boolean;
destroyed: boolean;
_data: unknown;
_encoding: BufferEncoding;
constructor(_opts?: NodeStream.WritableOptions);
pipe<T>(_destenition: T, _options?: {
end?: boolean;
}): T;
_write(chunk: any, encoding: BufferEncoding, callback?: Callback): void;
_writev?(_chunks: Array<{
chunk: any;
encoding: BufferEncoding;
}>, _callback: (error?: Error | null) => void): void;
_destroy(_error: any, _callback: Callback<any>): void;
_final(_callback: Callback): void;
write(chunk: any, arg2?: BufferEncoding | Callback, arg3?: Callback): boolean;
setDefaultEncoding(_encoding: BufferEncoding): this;
end(arg1: Callback | any, arg2?: Callback | BufferEncoding, arg3?: Callback): this;
cork(): void;
uncork(): void;
destroy(_error?: Error): this;
compose<T extends NodeJS.ReadableStream>(_stream: T | ((source: any) => void) | Iterable<T> | AsyncIterable<T>, _options?: {
signal: AbortSignal;
} | undefined): T;
}
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse {
statusCode: number;
statusMessage: string;
upgrading: boolean;
chunkedEncoding: boolean;
shouldKeepAlive: boolean;
useChunkedEncodingByDefault: boolean;
sendDate: boolean;
finished: boolean;
headersSent: boolean;
strictContentLength: boolean;
connection: Socket$1 | null;
socket: Socket$1 | null;
req: NodeHTTP.IncomingMessage;
_headers: Record<string, number | string | string[] | undefined>;
constructor(req: NodeHTTP.IncomingMessage);
assignSocket(socket: Socket$1): void;
_flush(): void;
detachSocket(_socket: Socket$1): void;
writeContinue(_callback?: Callback): void;
writeHead(statusCode: number, arg1?: string | NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[], arg2?: NodeHTTP.OutgoingHttpHeaders | NodeHTTP.OutgoingHttpHeader[]): this;
writeProcessing(): void;
setTimeout(_msecs: number, _callback?: Callback): this;
appendHeader(name: string, value: string | string[]): this;
setHeader(name: string, value: number | string | string[]): this;
setHeaders(headers: Headers | Map<string, number | string | readonly string[]>): this;
getHeader(name: string): number | string | string[] | undefined;
getHeaders(): NodeHTTP.OutgoingHttpHeaders;
getHeaderNames(): string[];
hasHeader(name: string): boolean;
removeHeader(name: string): void;
addTrailers(_headers: NodeHTTP.OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
flushHeaders(): void;
writeEarlyHints(_headers: NodeHTTP.OutgoingHttpHeaders, cb: () => void): void;
}
type MaybePromise<T> = T | Promise<T>;
type NodeRequestHandler = (req: IncomingMessage, res: ServerResponse) => MaybePromise<void | unknown>;
type NodeRequestHeaders = Record<string, string | string[]>;
type NodeResponseHeaders = Record<string, string | undefined | number | string[]>;
type AbstractRequest = {
[key: string]: any;
url?: URL | string;
method?: string;
headers?: HeadersInit | NodeRequestHeaders;
protocol?: string;
body?: any;
};
type AbstractResponse = {
body: any;
headers: NodeResponseHeaders;
status: number;
statusText: string;
};
declare function callNodeRequestHandler(handler: NodeRequestHandler, aRequest: AbstractRequest): Promise<AbstractResponse>;
declare function fetchNodeRequestHandler(handler: NodeRequestHandler, url: string | URL, init?: RequestInit): Promise<Response>;
export { type AbstractRequest, type AbstractResponse, IncomingMessage, type NodeRequestHandler, type NodeRequestHeaders, type NodeResponseHeaders, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
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};
MIT License
Copyright (c)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# node-mock-http
<!-- automd:badges color=yellow -->
[![npm version](https://img.shields.io/npm/v/node-mock-http?color=yellow)](https://npmjs.com/package/node-mock-http)
[![npm downloads](https://img.shields.io/npm/dm/node-mock-http?color=yellow)](https://npm.chart.dev/node-mock-http)
<!-- /automd -->
Node.js [`http.IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) and [`http.ServerResponse`](https://nodejs.org/api/http.html#class-httpserverresponse) mocked implementations that allows emulate calling Node.js http handlers. (based on [unjs/unenv v1](https://github.com/unjs/unenv/tree/v1)).
## Usage
> [!NOTE]
> Documentation is incomplete!
```js
import { fetchNodeRequestHandler } from "node-mock-http";
const nodeHandler = (req, res) => {
res.end("OK!");
};
const res = await fetchNodeRequestHandler(
nodeHandler,
"http://example.com/test",
);
```
## Development
<details>
<summary>local development</summary>
- Clone this repository
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`
</details>
## License
<!-- automd:contributors license=MIT -->
Published under the [MIT](https://github.com/unjs/node-mock-http/blob/main/LICENSE) license.
Made by [community](https://github.com/unjs/node-mock-http/graphs/contributors) 💛
<br><br>
<a href="https://github.com/unjs/node-mock-http/graphs/contributors">
<img src="https://contrib.rocks/image?repo=unjs/node-mock-http" />
</a>
<!-- /automd -->
<!-- automd:with-automd -->
---
_🤖 auto updated with [automd](https://automd.unjs.io)_
<!-- /automd -->
+60
-1
{
"name": "node-mock-http",
"version": "0.0.0"
"version": "0.1.0",
"description": "",
"repository": "unjs/node-mock-http",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./_polyfill/buffer": {
"import": {
"node": "./dist/_polyfill/buffer/node.mjs",
"default": "./dist/_polyfill/buffer/nodeless.mjs"
},
"require": {
"node": "./dist/_polyfill/buffer/node.cjs",
"default": "./dist/_polyfill/buffer/nodeless.cjs"
}
},
"./_polyfill/events": {
"import": {
"node": "./dist/_polyfill/events/node.mjs",
"default": "./dist/_polyfill/events/nodeless.mjs"
},
"require": {
"node": "./dist/_polyfill/events/node.cjs",
"default": "./dist/_polyfill/events/nodeless.cjs"
}
}
},
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "unbuild --minify",
"dev": "vitest dev --coverage",
"lint": "eslint . && prettier -c .",
"lint:fix": "automd && eslint . --fix && prettier -w .",
"prepack": "pnpm build",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
"test:types": "tsc --noEmit --skipLibCheck"
},
"devDependencies": {
"@types/node": "^22.12.0",
"@vitest/coverage-v8": "^3.0.4",
"automd": "^0.3.12",
"changelogen": "^0.5.7",
"eslint": "^9.19.0",
"eslint-config-unjs": "^0.4.2",
"jiti": "^2.4.2",
"prettier": "^3.4.2",
"typescript": "^5.7.3",
"unbuild": "^3.3.1",
"vitest": "^3.0.4"
},
"packageManager": "pnpm@9.15.4"
}