Astro+Directus(Visual-Editing)+Snipcart Test-Stack
This commit is contained in:
commit
1459e99cb0
10119 files changed
+1499318
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
# node-mock-http
|
||||
|
||||
<!-- automd:badges color=yellow -->
|
||||
|
||||
[](https://npmjs.com/package/node-mock-http)
|
||||
[](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`
|
||||
- Build project in stub mode using `pnpm build --stub`
|
||||
- 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 -->
|
||||
+1
@@ -0,0 +1 @@
|
||||
"use strict";const node_buffer=require("node:buffer");exports.Buffer=node_buffer.Buffer;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { Buffer } from 'node:buffer';
|
||||
import 'node:events';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { Buffer } from 'node:buffer';
|
||||
import 'node:events';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { Buffer } from 'node:buffer';
|
||||
import 'node:events';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export{Buffer}from"node:buffer";
|
||||
+1
@@ -0,0 +1 @@
|
||||
"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 o=n===e?0:4-n%4;return[n,o]}function p(t,e,n){return(e+n)*3/4-n}function toByteArray(t){let e;const n=d$1(t),o=n[0],r=n[1],f=new x$1(p(t,o,r));let h=0;const E=r>0?o-4:o;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 r===2&&(e=l[t.charCodeAt(U)]<<2|l[t.charCodeAt(U+1)]>>4,f[h++]=e&255),r===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 o;const r=[];for(let f=e;f<n;f+=3)o=(t[f]<<16&16711680)+(t[f+1]<<8&65280)+(t[f+2]&255),r.push(u(o));return r.join("")}function fromByteArray(t){let e;const n=t.length,o=n%3,r=[],f=16383;for(let h=0,E=n-o;h<E;h+=f)r.push(A$1(t,h,h+f>E?E:h+f));return o===1?(e=t[n-1],r.push(a$1[e>>2]+a$1[e<<4&63]+"==")):o===2&&(e=(t[n-2]<<8)+t[n-1],r.push(a$1[e>>10]+a$1[e>>4&63]+a$1[e<<2&63]+"=")),r.join("")}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function read(t,e,n,o,r){let f,h;const E=r*8-o-1,U=(1<<E)-1,et=U>>1;let c=-7,tt=n?r-1:0;const ot=n?-1:1;let nt=t[e+tt];for(tt+=ot,f=nt&(1<<-c)-1,nt>>=-c,c+=E;c>0;)f=f*256+t[e+tt],tt+=ot,c-=8;for(h=f&(1<<-c)-1,f>>=-c,c+=o;c>0;)h=h*256+t[e+tt],tt+=ot,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,o),f=f-et}return(nt?-1:1)*h*Math.pow(2,f-o)}function write(t,e,n,o,r,f){let h,E,U,et=f*8-r-1;const c=(1<<et)-1,tt=c>>1,ot=r===23?Math.pow(2,-24)-Math.pow(2,-77):0;let nt=o?0:f-1;const rt=o?1:-1,it=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?ot/U:ot*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,r),h=h+tt):(E=e*Math.pow(2,tt-1)*Math.pow(2,r),h=0));r>=8;)t[n+nt]=E&255,nt+=rt,E/=256,r-=8;for(h=h<<r|E,et+=r;et>0;)t[n+nt]=h&255,nt+=rt,h/=256,et-=8;t[n+nt-rt]|=it*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 o=t.valueOf&&t.valueOf();if(o!=null&&o!==t)return Buffer.from(o,e,n);const r=Z(t);if(r)return r;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==Line truncated
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 };
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 };
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 };
|
||||
+1
@@ -0,0 +1 @@
|
||||
const d=[],y=[],ot=typeof Uint8Array>"u"?Array:Uint8Array,L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=L.length;t<e;++t)d[t]=L[t],y[L.charCodeAt(t)]=t;y[45]=62,y[95]=63;function rt(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 o=n===e?0:4-n%4;return[n,o]}function it(t,e,n){return(e+n)*3/4-n}function ft(t){let e;const n=rt(t),o=n[0],r=n[1],i=new ot(it(t,o,r));let u=0;const h=r>0?o-4:o;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)],i[u++]=e>>16&255,i[u++]=e>>8&255,i[u++]=e&255;return r===2&&(e=y[t.charCodeAt(c)]<<2|y[t.charCodeAt(c+1)]>>4,i[u++]=e&255),r===1&&(e=y[t.charCodeAt(c)]<<10|y[t.charCodeAt(c+1)]<<4|y[t.charCodeAt(c+2)]>>2,i[u++]=e>>8&255,i[u++]=e&255),i}function ut(t){return d[t>>18&63]+d[t>>12&63]+d[t>>6&63]+d[t&63]}function st(t,e,n){let o;const r=[];for(let i=e;i<n;i+=3)o=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),r.push(ut(o));return r.join("")}function P(t){let e;const n=t.length,o=n%3,r=[],i=16383;for(let u=0,h=n-o;u<h;u+=i)r.push(st(t,u,u+i>h?h:u+i));return o===1?(e=t[n-1],r.push(d[e>>2]+d[e<<4&63]+"==")):o===2&&(e=(t[n-2]<<8)+t[n-1],r.push(d[e>>10]+d[e>>4&63]+d[e<<2&63]+"=")),r.join("")}/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function R(t,e,n,o,r){let i,u;const h=r*8-o-1,c=(1<<h)-1,l=c>>1;let s=-7,a=n?r-1:0;const I=n?-1:1;let w=t[e+a];for(a+=I,i=w&(1<<-s)-1,w>>=-s,s+=h;s>0;)i=i*256+t[e+a],a+=I,s-=8;for(u=i&(1<<-s)-1,i>>=-s,s+=o;s>0;)u=u*256+t[e+a],a+=I,s-=8;if(i===0)i=1-l;else{if(i===c)return u?Number.NaN:(w?-1:1)*Number.POSITIVE_INFINITY;u=u+Math.pow(2,o),i=i-l}return(w?-1:1)*u*Math.pow(2,i-o)}function F(t,e,n,o,r,i){let u,h,c,l=i*8-r-1;const s=(1<<l)-1,a=s>>1,I=r===23?Math.pow(2,-24)-Math.pow(2,-77):0;let w=o?0:i-1;const O=o?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,r),u=u+a):(h=e*Math.pow(2,a-1)*Math.pow(2,r),u=0));r>=8;)t[n+w]=h&255,w+=O,h/=256,r-=8;for(u=u<<r|h,l+=r;l>0;)t[n+w]=u&255,w+=O,u/=256,l-=8;t[n+w-O]|=nt*128}const k=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null,ht=50,N=2147483647;f.TYPED_ARRAY_SUPPORT=ct(),!f.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(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function m(t){if(t>N)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(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 S(t)}return j(t,e,n)}f.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 o=t.valueOf&&t.valueOf();if(o!=null&&o!==t)return f.from(o,e,n);const r=gt(t);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return f.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)}f.from=function(t,e,n){return j(t,e,n)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,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)}f.alloc=function(t,e,n){return at(t,e,n)};function S(t){return D(t),m(t<0?0:x(t)|0)}f.allocUnsafe=function(t){return S(t)},f.allocUnsafeSlow=functLine truncated
|
||||
+1
@@ -0,0 +1 @@
|
||||
"use strict";const node_events=require("node:events");exports.EventEmitter=node_events.EventEmitter;
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { EventEmitter } from 'node:events';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { EventEmitter } from 'node:events';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { EventEmitter } from 'node:events';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export{EventEmitter}from"node:events";
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";let y=10;const Y=Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf((async function*(){})()))),F=(e,t)=>e,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(t=y,...r){if(r.length===0)y=t;else for(const n of r)if($(n))n[w]=t,n[W]=!1;else if(typeof n.setMaxListeners=="function")n.setMaxListeners(t);else throw new h("eventTargets",["EventEmitter","EventTarget"],n)}static listenerCount(t,r){if(typeof t.listenerCount=="function")return t.listenerCount(r);EventEmitter.prototype.listenerCount.call(t,r)}static init(){throw new Error("EventEmitter.init() is not implemented.")}static get captureRejections(){return this[l]}static set captureRejections(t){this[l]=t}static get defaultMaxListeners(){return y}static set defaultMaxListeners(t){y=t}constructor(t){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,t?.captureRejections?this[l]=!!t.captureRejections:this[l]=EventEmitter.prototype[l]}setMaxListeners(t){return this._maxListeners=t,this}getMaxListeners(){return S(this)}emit(t,...r){let n=t==="error";const s=this._events;if(s!==void 0)n&&s[A]!==void 0&&this.emit(A,...r),n=n&&s.error===void 0;else if(!n)return!1;if(n){let i;if(r.length>0&&(i=r[0]),i instanceof Error){try{const f={};Error.captureStackTrace?.(f,EventEmitter.prototype.emit),Object.defineProperty(i,ee,{__proto__:null,value:Function.prototype.bind(re,this,i,f),configurable:!0})}catch{}throw i}let u;try{u=F(i)}catch{u=i}const a=new J(u);throw a.context=i,a}const o=s[t];if(o===void 0)return!1;if(typeof o=="function"){const i=o.apply(this,r);i!=null&&H(this,i,t,r)}else{const i=o.length,u=C(o);for(let a=0;a<i;++a){const f=u[a].apply(this,r);f!=null&&H(this,f,t,r)}}return!0}addListener(t,r){return z(this,t,r,!1),this}on(t,r){return this.addListener(t,r)}prependListener(t,r){return z(this,t,r,!0),this}once(t,r){return this.on(t,U(this,t,r)),this}prependOnceListener(t,r){return this.prependListener(t,U(this,t,r)),this}removeListener(t,r){const n=this._events;if(n===void 0)return this;const s=n[t];if(s===void 0)return this;if(s===r||s.listener===r)this._eventsCount-=1,this[p]?n[t]=void 0:this._eventsCount===0?this._events={__proto__:null}:(delete n[t],n.removeListener&&this.emit("removeListener",t,s.listener||r));else if(typeof s!="function"){let o=-1;for(let i=s.length-1;i>=0;i--)if(s[i]===r||s[i].listener===r){o=i;break}if(o<0)return this;o===0?s.shift():ce(s,o),s.length===1&&(n[t]=s[0]),n.removeListener!==void 0&&this.emit("removeListener",t,r)}return this}off(t,r){return this.removeListener(t,r)}removeAllListeners(t){const r=this._events;if(r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events={__proto__:null},this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events={__proto__:null}:delete r[t]),this[p]=!1,this;if(arguments.length===0){for(const s of Reflect.ownKeys(r))s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events={__proto__:null},this._eventsCount=0,this[p]=!1,this}const n=r[t];if(typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(let s=n.length-1;s>=0;s--)this.removeListener(t,n[s]);return this}listeners(t){return G(this,t,!0)}rawListeners(t){return G(this,t,!1)}eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}listenerCount(t,r){const n=this._events;if(n!==void 0){const s=n[t];if(typeof s=="function")return r!=null?r===s||r===s.listener?1:0:1;if(s!==void 0){if(r!=null){let o=0;for(let i=0,u=s.length;i<u;i++)(s[i]===r||s[i].listener===r)&&o++;return o}return s.length}}return 0}}class EventEmitterAsyncResource extends EventEmitter{constructor(t){let r;typeof t=="string"?(r=t,t=void 0):r=t?.name||new.target.name,super(t),this[E]=new EventEmitterReferencingAsyncResource(this,r,t)}emit(t,...r){if(this[E]===void 0)throw new g("EventEmitterAsyncResource");const{asynLine truncated
|
||||
Emitted 'error' event${r} at:
|
||||
`,s=(t.stack||"").split(`
|
||||
`).slice(1);return e.stack+n+s.join(`
|
||||
`)}function z(e,t,r,n){let s,o,i;if(o=e._events,o===void 0?(o=e._events={__proto__:null},e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener??r),o=e._events),i=o[t]),i===void 0)o[t]=r,++e._eventsCount;else if(typeof i=="function"?i=o[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),s=S(e),s>0&&i.length>s&&!i.warned){i.warned=!0;const u=new Z(`Possible EventEmitter memory leak detected. ${i.length} ${String(t)} listeners added to ${F(e)}. MaxListeners is ${s}. Use emitter.setMaxListeners() to increase limit`,{name:"MaxListenersExceededWarning",emitter:e,type:t,count:i.length});process.emitWarning(u)}return e}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(e,t,r){const n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=ie.bind(n);return s.listener=r,n.wrapFn=s,s}function G(e,t,r){const n=e._events;if(n===void 0)return[];const s=n[t];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?oe(s):C(s)}function C(e){switch(e.length){case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];case 4:return[e[0],e[1],e[2],e[3]];case 5:return[e[0],e[1],e[2],e[3],e[4]];case 6:return[e[0],e[1],e[2],e[3],e[4],e[5]]}return Array.prototype.slice.call(e)}function oe(e){const t=C(e);for(let r=0;r<t.length;++r){const n=t[r].listener;typeof n=="function"&&(t[r]=n)}return t}function T(e,t){return{value:e,done:t}}function L(e,t,r,n){if(typeof e.removeListener=="function")e.removeListener(t,r);else if(typeof e.removeEventListener=="function")e.removeEventListener(t,r,n);else throw new h("emitter","EventEmitter",e)}function P(e,t,r,n){if(typeof e.on=="function")n?.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,r,n);else throw new h("emitter","EventEmitter",e)}function ue(){const e=[];return{addEventListener(t,r,n,s){P(t,r,n,s),Array.prototype.push(e,[t,r,n,s])},removeAll(){for(;e.length>0;)Reflect.apply(L,void 0,e.pop())}}}function ce(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}exports.EventEmitter=EventEmitter;
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
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 };
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
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 };
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
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 };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
let y=10;const Y=Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf((async function*(){})()))),F=(e,t)=>e,_=Error,Z=Error,h=Error,w=Error,tt=Error,R=Symbol.for("nodejs.rejection"),f=Symbol.for("kCapture"),M=Symbol.for("events.errorMonitor"),g=Symbol.for("shapeMode"),b=Symbol.for("events.maxEventTargetListeners"),et=Symbol.for("kEnhanceStackBeforeInspector"),rt=Symbol.for("nodejs.watermarkData"),v=Symbol.for("kAsyncResource"),nt=Symbol.for("kFirstEventParam"),S=Symbol.for("kResistStopPropagation"),W=Symbol.for("events.maxEventTargetListenersWarned");class m{_events=void 0;_eventsCount=0;_maxListeners=y;[f]=!1;[g]=!1;static captureRejectionSymbol=R;static errorMonitor=M;static kMaxEventTargetListeners=b;static kMaxEventTargetListenersWarned=W;static usingDomains=!1;static get on(){return it}static get once(){return ot}static get getEventListeners(){return ct}static get getMaxListeners(){return ut}static get addAbortListener(){return $}static get EventEmitterAsyncResource(){return st}static get EventEmitter(){return m}static setMaxListeners(t=y,...r){if(r.length===0)y=t;else for(const n of r)if(q(n))n[b]=t,n[W]=!1;else if(typeof n.setMaxListeners=="function")n.setMaxListeners(t);else throw new h("eventTargets",["EventEmitter","EventTarget"],n)}static listenerCount(t,r){if(typeof t.listenerCount=="function")return t.listenerCount(r);m.prototype.listenerCount.call(t,r)}static init(){throw new Error("EventEmitter.init() is not implemented.")}static get captureRejections(){return this[f]}static set captureRejections(t){this[f]=t}static get defaultMaxListeners(){return y}static set defaultMaxListeners(t){y=t}constructor(t){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,t?.captureRejections?this[f]=!!t.captureRejections:this[f]=m.prototype[f]}setMaxListeners(t){return this._maxListeners=t,this}getMaxListeners(){return j(this)}emit(t,...r){let n=t==="error";const s=this._events;if(s!==void 0)n&&s[M]!==void 0&&this.emit(M,...r),n=n&&s.error===void 0;else if(!n)return!1;if(n){let i;if(r.length>0&&(i=r[0]),i instanceof Error){try{const a={};Error.captureStackTrace?.(a,m.prototype.emit),Object.defineProperty(i,et,{__proto__:null,value:Function.prototype.bind(at,this,i,a),configurable:!0})}catch{}throw i}let u;try{u=F(i)}catch{u=i}const l=new Z(u);throw l.context=i,l}const o=s[t];if(o===void 0)return!1;if(typeof o=="function"){const i=o.apply(this,r);i!=null&&z(this,i,t,r)}else{const i=o.length,u=C(o);for(let l=0;l<i;++l){const a=u[l].apply(this,r);a!=null&&z(this,a,t,r)}}return!0}addListener(t,r){return B(this,t,r,!1),this}on(t,r){return this.addListener(t,r)}prependListener(t,r){return B(this,t,r,!0),this}once(t,r){return this.on(t,G(this,t,r)),this}prependOnceListener(t,r){return this.prependListener(t,G(this,t,r)),this}removeListener(t,r){const n=this._events;if(n===void 0)return this;const s=n[t];if(s===void 0)return this;if(s===r||s.listener===r)this._eventsCount-=1,this[g]?n[t]=void 0:this._eventsCount===0?this._events={__proto__:null}:(delete n[t],n.removeListener&&this.emit("removeListener",t,s.listener||r));else if(typeof s!="function"){let o=-1;for(let i=s.length-1;i>=0;i--)if(s[i]===r||s[i].listener===r){o=i;break}if(o<0)return this;o===0?s.shift():mt(s,o),s.length===1&&(n[t]=s[0]),n.removeListener!==void 0&&this.emit("removeListener",t,r)}return this}off(t,r){return this.removeListener(t,r)}removeAllListeners(t){const r=this._events;if(r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events={__proto__:null},this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events={__proto__:null}:delete r[t]),this[g]=!1,this;if(arguments.length===0){for(const s of Reflect.ownKeys(r))s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events={__proto__:null},this._eventsCount=0,this[g]=!1,this}const n=r[t];if(typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(let s=n.length-1;s>=0;s--)this.removeListener(t,n[s]);return this}listeners(t){return U(this,t,!0)}rawListeners(t){return U(this,t,!1)}eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}listenerCount(t,r){const n=this._events;if(n!==void 0){const s=n[t];if(typeof s=="function")return r!=null?r===s||r===s.listener?1:0:1;if(s!==void 0){if(r!=null){let o=0;for(let i=0,u=s.length;i<u;i++)(s[i]===r||s[i].listener===r)&&o++;return o}return s.length}}return 0}}class st extends m{constructor(t){let r;typeof t=="string"?(r=t,t=void 0):r=t?.name||new.target.name,super(t),this[v]=new EventEmitterReferencingAsyncResource(this,r,t)}emit(t,...r){if(this[v]===void 0)throw new _("EventEmitterAsyncResource");const{asyncResource:n}=this;return Array.prototype.unshift(r,super.emit,this,t),Reflect.apply(n.runInAsyncScope,n,r)}emitDestroy(){if(this[v]===void 0)throw new _("EventEmitterAsyLine truncated
|
||||
Emitted 'error' event${r} at:
|
||||
`,s=(t.stack||"").split(`
|
||||
`).slice(1);return e.stack+n+s.join(`
|
||||
`)}function B(e,t,r,n){let s,o,i;if(o=e._events,o===void 0?(o=e._events={__proto__:null},e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,r.listener??r),o=e._events),i=o[t]),i===void 0)o[t]=r,++e._eventsCount;else if(typeof i=="function"?i=o[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),s=j(e),s>0&&i.length>s&&!i.warned){i.warned=!0;const u=new tt(`Possible EventEmitter memory leak detected. ${i.length} ${String(t)} listeners added to ${F(e)}. MaxListeners is ${s}. Use emitter.setMaxListeners() to increase limit`,{name:"MaxListenersExceededWarning",emitter:e,type:t,count:i.length});process.emitWarning(u)}return e}function ft(){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(e,t,r){const n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=ft.bind(n);return s.listener=r,n.wrapFn=s,s}function U(e,t,r){const n=e._events;if(n===void 0)return[];const s=n[t];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?ht(s):C(s)}function C(e){switch(e.length){case 2:return[e[0],e[1]];case 3:return[e[0],e[1],e[2]];case 4:return[e[0],e[1],e[2],e[3]];case 5:return[e[0],e[1],e[2],e[3],e[4]];case 6:return[e[0],e[1],e[2],e[3],e[4],e[5]]}return Array.prototype.slice.call(e)}function ht(e){const t=C(e);for(let r=0;r<t.length;++r){const n=t[r].listener;typeof n=="function"&&(t[r]=n)}return t}function P(e,t){return{value:e,done:t}}function E(e,t,r,n){if(typeof e.removeListener=="function")e.removeListener(t,r);else if(typeof e.removeEventListener=="function")e.removeEventListener(t,r,n);else throw new h("emitter","EventEmitter",e)}function O(e,t,r,n){if(typeof e.on=="function")n?.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,r,n);else throw new h("emitter","EventEmitter",e)}function vt(){const e=[];return{addEventListener(t,r,n,s){O(t,r,n,s),Array.prototype.push(e,[t,r,n,s])},removeAll(){for(;e.length>0;)Reflect.apply(E,void 0,e.pop())}}}function mt(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}export{m as EventEmitter};
|
||||
+1
@@ -0,0 +1 @@
|
||||
"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;writableAborted=!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.")}[Symbol.asyncDispose](){return Promise.resolve()}}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)}}fLine truncated
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
import NodeHTTP, { IncomingMessage as IncomingMessage$1 } 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 | undefined;
|
||||
readonly remoteFamily: string | undefined;
|
||||
readonly remotePort: number | undefined;
|
||||
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>(_destination: 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;
|
||||
readonly writableAborted: 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;
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
|
||||
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse<IncomingMessage$1> {
|
||||
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 & AbstractRequest): Promise<Response>;
|
||||
|
||||
export { IncomingMessage, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
|
||||
export type { AbstractRequest, AbstractResponse, NodeRequestHandler, NodeRequestHeaders, NodeResponseHeaders };
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
import NodeHTTP, { IncomingMessage as IncomingMessage$1 } 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 | undefined;
|
||||
readonly remoteFamily: string | undefined;
|
||||
readonly remotePort: number | undefined;
|
||||
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>(_destination: 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;
|
||||
readonly writableAborted: 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;
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
|
||||
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse<IncomingMessage$1> {
|
||||
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 & AbstractRequest): Promise<Response>;
|
||||
|
||||
export { IncomingMessage, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
|
||||
export type { AbstractRequest, AbstractResponse, NodeRequestHandler, NodeRequestHeaders, NodeResponseHeaders };
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
import NodeHTTP, { IncomingMessage as IncomingMessage$1 } 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 | undefined;
|
||||
readonly remoteFamily: string | undefined;
|
||||
readonly remotePort: number | undefined;
|
||||
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>(_destination: 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;
|
||||
readonly writableAborted: 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;
|
||||
[Symbol.asyncDispose](): Promise<void>;
|
||||
}
|
||||
|
||||
declare class ServerResponse extends Writable implements NodeHTTP.ServerResponse<IncomingMessage$1> {
|
||||
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 & AbstractRequest): Promise<Response>;
|
||||
|
||||
export { IncomingMessage, ServerResponse, callNodeRequestHandler, fetchNodeRequestHandler };
|
||||
export type { AbstractRequest, AbstractResponse, NodeRequestHandler, NodeRequestHeaders, NodeResponseHeaders };
|
||||
+1
@@ -0,0 +1 @@
|
||||
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;writableAborted=!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.")}[Symbol.asyncDispose](){return Promise.resolve()}}const c=class{allowHalfOpen=!0;_destroy;constructor(e=new i,t=new l){Object.assign(this,e),Object.assign(this,t),this._destroy=m(e._destroy,t._destroy)}};function _(){return Object.assign(c.prototype,i.prototype),Object.assign(c.prototype,l.prototype),c}function m(...n){return function(...e){for(const t of n)t(...e)}}const g=_();class A extends g{__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){}wrLine truncated
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "node-mock-http",
|
||||
"version": "1.0.4",
|
||||
"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": "^24.10.1",
|
||||
"@vitest/coverage-v8": "^4.0.15",
|
||||
"automd": "^0.4.2",
|
||||
"changelogen": "^0.6.2",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-config-unjs": "^0.5.0",
|
||||
"jiti": "^2.6.1",
|
||||
"prettier": "^3.7.4",
|
||||
"typescript": "^5.9.3",
|
||||
"unbuild": "^3.6.1",
|
||||
"vitest": "^4.0.15"
|
||||
},
|
||||
"packageManager": "pnpm@10.24.0"
|
||||
}
|
||||
Reference in new issue
Block a user