Sylvain Filoni commited on
Commit
48e84aa
1 Parent(s): 4792bf6
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Dockerfile +6 -0
  2. README.md +6 -4
  3. index.js +19 -0
  4. node_modules/.bin/mime +1 -0
  5. node_modules/@socket.io/component-emitter/LICENSE +24 -0
  6. node_modules/@socket.io/component-emitter/Readme.md +74 -0
  7. node_modules/@socket.io/component-emitter/index.d.ts +179 -0
  8. node_modules/@socket.io/component-emitter/index.js +176 -0
  9. node_modules/@socket.io/component-emitter/index.mjs +169 -0
  10. node_modules/@socket.io/component-emitter/package.json +61 -0
  11. node_modules/@types/cookie/LICENSE +21 -0
  12. node_modules/@types/cookie/README.md +16 -0
  13. node_modules/@types/cookie/index.d.ts +135 -0
  14. node_modules/@types/cookie/package.json +57 -0
  15. node_modules/@types/cors/LICENSE +21 -0
  16. node_modules/@types/cors/README.md +80 -0
  17. node_modules/@types/cors/index.d.ts +60 -0
  18. node_modules/@types/cors/package.json +59 -0
  19. node_modules/@types/node/LICENSE +21 -0
  20. node_modules/@types/node/README.md +16 -0
  21. node_modules/@types/node/assert.d.ts +961 -0
  22. node_modules/@types/node/assert/strict.d.ts +8 -0
  23. node_modules/@types/node/async_hooks.d.ts +513 -0
  24. node_modules/@types/node/buffer.d.ts +0 -0
  25. node_modules/@types/node/child_process.d.ts +1369 -0
  26. node_modules/@types/node/cluster.d.ts +410 -0
  27. node_modules/@types/node/console.d.ts +412 -0
  28. node_modules/@types/node/constants.d.ts +18 -0
  29. node_modules/@types/node/crypto.d.ts +0 -0
  30. node_modules/@types/node/dgram.d.ts +545 -0
  31. node_modules/@types/node/diagnostics_channel.d.ts +153 -0
  32. node_modules/@types/node/dns.d.ts +659 -0
  33. node_modules/@types/node/dns/promises.d.ts +370 -0
  34. node_modules/@types/node/dom-events.d.ts +126 -0
  35. node_modules/@types/node/domain.d.ts +170 -0
  36. node_modules/@types/node/events.d.ts +678 -0
  37. node_modules/@types/node/fs.d.ts +0 -0
  38. node_modules/@types/node/fs/promises.d.ts +1138 -0
  39. node_modules/@types/node/globals.d.ts +300 -0
  40. node_modules/@types/node/globals.global.d.ts +1 -0
  41. node_modules/@types/node/http.d.ts +1651 -0
  42. node_modules/@types/node/http2.d.ts +0 -0
  43. node_modules/@types/node/https.d.ts +542 -0
  44. node_modules/@types/node/index.d.ts +134 -0
  45. node_modules/@types/node/inspector.d.ts +0 -0
  46. node_modules/@types/node/module.d.ts +115 -0
  47. node_modules/@types/node/net.d.ts +883 -0
  48. node_modules/@types/node/os.d.ts +473 -0
  49. node_modules/@types/node/package.json +225 -0
  50. node_modules/@types/node/path.d.ts +191 -0
Dockerfile ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ FROM node:latest
2
+
3
+ COPY . .
4
+
5
+ RUN npm install
6
+ CMD node index.js
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Controlnet Animation Doodle
3
- emoji: 🚀
4
- colorFrom: green
5
- colorTo: purple
6
  sdk: docker
 
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: ControlNet Animation Doodle
3
+ emoji: 🐳
4
+ colorFrom: indigo
5
+ colorTo: blue
6
  sdk: docker
7
+ app_file: app.py
8
  pinned: false
9
+ license: mit
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require("express");
2
+ const { createServer } = require("http");
3
+ const { Server } = require("socket.io");
4
+
5
+ const app = express();
6
+ const httpServer = createServer(app);
7
+ app.use(express.static('public'));
8
+ const io = new Server(httpServer, { /* options */ });
9
+
10
+ io.on("connection", (socket) => {
11
+ console.log("hello sockets")
12
+ socket.emit("hello", (process.env.HF_SECRET_VALUE));
13
+ });
14
+
15
+ httpServer.listen(7860);
16
+
17
+
18
+
19
+
node_modules/.bin/mime ADDED
@@ -0,0 +1 @@
 
 
1
+ ../mime/cli.js
node_modules/@socket.io/component-emitter/LICENSE ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014 Component contributors <[email protected]>
4
+
5
+ Permission is hereby granted, free of charge, to any person
6
+ obtaining a copy of this software and associated documentation
7
+ files (the "Software"), to deal in the Software without
8
+ restriction, including without limitation the rights to use,
9
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
node_modules/@socket.io/component-emitter/Readme.md ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)
2
+
3
+ Event emitter component.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ component install component/emitter
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### Emitter(obj)
14
+
15
+ The `Emitter` may also be used as a mixin. For example
16
+ a "plain" object may become an emitter, or you may
17
+ extend an existing prototype.
18
+
19
+ As an `Emitter` instance:
20
+
21
+ ```js
22
+ var Emitter = require('emitter');
23
+ var emitter = new Emitter;
24
+ emitter.emit('something');
25
+ ```
26
+
27
+ As a mixin:
28
+
29
+ ```js
30
+ var Emitter = require('emitter');
31
+ var user = { name: 'tobi' };
32
+ Emitter(user);
33
+
34
+ user.emit('im a user');
35
+ ```
36
+
37
+ As a prototype mixin:
38
+
39
+ ```js
40
+ var Emitter = require('emitter');
41
+ Emitter(User.prototype);
42
+ ```
43
+
44
+ ### Emitter#on(event, fn)
45
+
46
+ Register an `event` handler `fn`.
47
+
48
+ ### Emitter#once(event, fn)
49
+
50
+ Register a single-shot `event` handler `fn`,
51
+ removed immediately after it is invoked the
52
+ first time.
53
+
54
+ ### Emitter#off(event, fn)
55
+
56
+ * Pass `event` and `fn` to remove a listener.
57
+ * Pass `event` to remove all listeners on that event.
58
+ * Pass nothing to remove all listeners on all events.
59
+
60
+ ### Emitter#emit(event, ...)
61
+
62
+ Emit an `event` with variable option args.
63
+
64
+ ### Emitter#listeners(event)
65
+
66
+ Return an array of callbacks, or an empty array.
67
+
68
+ ### Emitter#hasListeners(event)
69
+
70
+ Check if this emitter has `event` handlers.
71
+
72
+ ## License
73
+
74
+ MIT
node_modules/@socket.io/component-emitter/index.d.ts ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * An events map is an interface that maps event names to their value, which
3
+ * represents the type of the `on` listener.
4
+ */
5
+ export interface EventsMap {
6
+ [event: string]: any;
7
+ }
8
+
9
+ /**
10
+ * The default events map, used if no EventsMap is given. Using this EventsMap
11
+ * is equivalent to accepting all event names, and any data.
12
+ */
13
+ export interface DefaultEventsMap {
14
+ [event: string]: (...args: any[]) => void;
15
+ }
16
+
17
+ /**
18
+ * Returns a union type containing all the keys of an event map.
19
+ */
20
+ export type EventNames<Map extends EventsMap> = keyof Map & (string | symbol);
21
+
22
+ /** The tuple type representing the parameters of an event listener */
23
+ export type EventParams<
24
+ Map extends EventsMap,
25
+ Ev extends EventNames<Map>
26
+ > = Parameters<Map[Ev]>;
27
+
28
+ /**
29
+ * The event names that are either in ReservedEvents or in UserEvents
30
+ */
31
+ export type ReservedOrUserEventNames<
32
+ ReservedEventsMap extends EventsMap,
33
+ UserEvents extends EventsMap
34
+ > = EventNames<ReservedEventsMap> | EventNames<UserEvents>;
35
+
36
+ /**
37
+ * Type of a listener of a user event or a reserved event. If `Ev` is in
38
+ * `ReservedEvents`, the reserved event listener is returned.
39
+ */
40
+ export type ReservedOrUserListener<
41
+ ReservedEvents extends EventsMap,
42
+ UserEvents extends EventsMap,
43
+ Ev extends ReservedOrUserEventNames<ReservedEvents, UserEvents>
44
+ > = FallbackToUntypedListener<
45
+ Ev extends EventNames<ReservedEvents>
46
+ ? ReservedEvents[Ev]
47
+ : Ev extends EventNames<UserEvents>
48
+ ? UserEvents[Ev]
49
+ : never
50
+ >;
51
+
52
+ /**
53
+ * Returns an untyped listener type if `T` is `never`; otherwise, returns `T`.
54
+ *
55
+ * This is a hack to mitigate https://github.com/socketio/socket.io/issues/3833.
56
+ * Needed because of https://github.com/microsoft/TypeScript/issues/41778
57
+ */
58
+ type FallbackToUntypedListener<T> = [T] extends [never]
59
+ ? (...args: any[]) => void | Promise<void>
60
+ : T;
61
+
62
+ /**
63
+ * Strictly typed version of an `EventEmitter`. A `TypedEventEmitter` takes type
64
+ * parameters for mappings of event names to event data types, and strictly
65
+ * types method calls to the `EventEmitter` according to these event maps.
66
+ *
67
+ * @typeParam ListenEvents - `EventsMap` of user-defined events that can be
68
+ * listened to with `on` or `once`
69
+ * @typeParam EmitEvents - `EventsMap` of user-defined events that can be
70
+ * emitted with `emit`
71
+ * @typeParam ReservedEvents - `EventsMap` of reserved events, that can be
72
+ * emitted by socket.io with `emitReserved`, and can be listened to with
73
+ * `listen`.
74
+ */
75
+ export class Emitter<
76
+ ListenEvents extends EventsMap,
77
+ EmitEvents extends EventsMap,
78
+ ReservedEvents extends EventsMap = {}
79
+ > {
80
+ /**
81
+ * Adds the `listener` function as an event listener for `ev`.
82
+ *
83
+ * @param ev Name of the event
84
+ * @param listener Callback function
85
+ */
86
+ on<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
87
+ ev: Ev,
88
+ listener: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
89
+ ): this;
90
+
91
+ /**
92
+ * Adds a one-time `listener` function as an event listener for `ev`.
93
+ *
94
+ * @param ev Name of the event
95
+ * @param listener Callback function
96
+ */
97
+ once<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
98
+ ev: Ev,
99
+ listener: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
100
+ ): this;
101
+
102
+ /**
103
+ * Removes the `listener` function as an event listener for `ev`.
104
+ *
105
+ * @param ev Name of the event
106
+ * @param listener Callback function
107
+ */
108
+ off<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
109
+ ev?: Ev,
110
+ listener?: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
111
+ ): this;
112
+
113
+ /**
114
+ * Emits an event.
115
+ *
116
+ * @param ev Name of the event
117
+ * @param args Values to send to listeners of this event
118
+ */
119
+ emit<Ev extends EventNames<EmitEvents>>(
120
+ ev: Ev,
121
+ ...args: EventParams<EmitEvents, Ev>
122
+ ): this;
123
+
124
+ /**
125
+ * Emits a reserved event.
126
+ *
127
+ * This method is `protected`, so that only a class extending
128
+ * `StrictEventEmitter` can emit its own reserved events.
129
+ *
130
+ * @param ev Reserved event name
131
+ * @param args Arguments to emit along with the event
132
+ */
133
+ protected emitReserved<Ev extends EventNames<ReservedEvents>>(
134
+ ev: Ev,
135
+ ...args: EventParams<ReservedEvents, Ev>
136
+ ): this;
137
+
138
+ /**
139
+ * Returns the listeners listening to an event.
140
+ *
141
+ * @param event Event name
142
+ * @returns Array of listeners subscribed to `event`
143
+ */
144
+ listeners<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
145
+ event: Ev
146
+ ): ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>[];
147
+
148
+ /**
149
+ * Returns true if there is a listener for this event.
150
+ *
151
+ * @param event Event name
152
+ * @returns boolean
153
+ */
154
+ hasListeners<
155
+ Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
156
+ >(event: Ev): boolean;
157
+
158
+ /**
159
+ * Removes the `listener` function as an event listener for `ev`.
160
+ *
161
+ * @param ev Name of the event
162
+ * @param listener Callback function
163
+ */
164
+ removeListener<
165
+ Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
166
+ >(
167
+ ev?: Ev,
168
+ listener?: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
169
+ ): this;
170
+
171
+ /**
172
+ * Removes all `listener` function as an event listener for `ev`.
173
+ *
174
+ * @param ev Name of the event
175
+ */
176
+ removeAllListeners<
177
+ Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
178
+ >(ev?: Ev): this;
179
+ }
node_modules/@socket.io/component-emitter/index.js ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * Expose `Emitter`.
4
+ */
5
+
6
+ exports.Emitter = Emitter;
7
+
8
+ /**
9
+ * Initialize a new `Emitter`.
10
+ *
11
+ * @api public
12
+ */
13
+
14
+ function Emitter(obj) {
15
+ if (obj) return mixin(obj);
16
+ }
17
+
18
+ /**
19
+ * Mixin the emitter properties.
20
+ *
21
+ * @param {Object} obj
22
+ * @return {Object}
23
+ * @api private
24
+ */
25
+
26
+ function mixin(obj) {
27
+ for (var key in Emitter.prototype) {
28
+ obj[key] = Emitter.prototype[key];
29
+ }
30
+ return obj;
31
+ }
32
+
33
+ /**
34
+ * Listen on the given `event` with `fn`.
35
+ *
36
+ * @param {String} event
37
+ * @param {Function} fn
38
+ * @return {Emitter}
39
+ * @api public
40
+ */
41
+
42
+ Emitter.prototype.on =
43
+ Emitter.prototype.addEventListener = function(event, fn){
44
+ this._callbacks = this._callbacks || {};
45
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
46
+ .push(fn);
47
+ return this;
48
+ };
49
+
50
+ /**
51
+ * Adds an `event` listener that will be invoked a single
52
+ * time then automatically removed.
53
+ *
54
+ * @param {String} event
55
+ * @param {Function} fn
56
+ * @return {Emitter}
57
+ * @api public
58
+ */
59
+
60
+ Emitter.prototype.once = function(event, fn){
61
+ function on() {
62
+ this.off(event, on);
63
+ fn.apply(this, arguments);
64
+ }
65
+
66
+ on.fn = fn;
67
+ this.on(event, on);
68
+ return this;
69
+ };
70
+
71
+ /**
72
+ * Remove the given callback for `event` or all
73
+ * registered callbacks.
74
+ *
75
+ * @param {String} event
76
+ * @param {Function} fn
77
+ * @return {Emitter}
78
+ * @api public
79
+ */
80
+
81
+ Emitter.prototype.off =
82
+ Emitter.prototype.removeListener =
83
+ Emitter.prototype.removeAllListeners =
84
+ Emitter.prototype.removeEventListener = function(event, fn){
85
+ this._callbacks = this._callbacks || {};
86
+
87
+ // all
88
+ if (0 == arguments.length) {
89
+ this._callbacks = {};
90
+ return this;
91
+ }
92
+
93
+ // specific event
94
+ var callbacks = this._callbacks['$' + event];
95
+ if (!callbacks) return this;
96
+
97
+ // remove all handlers
98
+ if (1 == arguments.length) {
99
+ delete this._callbacks['$' + event];
100
+ return this;
101
+ }
102
+
103
+ // remove specific handler
104
+ var cb;
105
+ for (var i = 0; i < callbacks.length; i++) {
106
+ cb = callbacks[i];
107
+ if (cb === fn || cb.fn === fn) {
108
+ callbacks.splice(i, 1);
109
+ break;
110
+ }
111
+ }
112
+
113
+ // Remove event specific arrays for event types that no
114
+ // one is subscribed for to avoid memory leak.
115
+ if (callbacks.length === 0) {
116
+ delete this._callbacks['$' + event];
117
+ }
118
+
119
+ return this;
120
+ };
121
+
122
+ /**
123
+ * Emit `event` with the given args.
124
+ *
125
+ * @param {String} event
126
+ * @param {Mixed} ...
127
+ * @return {Emitter}
128
+ */
129
+
130
+ Emitter.prototype.emit = function(event){
131
+ this._callbacks = this._callbacks || {};
132
+
133
+ var args = new Array(arguments.length - 1)
134
+ , callbacks = this._callbacks['$' + event];
135
+
136
+ for (var i = 1; i < arguments.length; i++) {
137
+ args[i - 1] = arguments[i];
138
+ }
139
+
140
+ if (callbacks) {
141
+ callbacks = callbacks.slice(0);
142
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
143
+ callbacks[i].apply(this, args);
144
+ }
145
+ }
146
+
147
+ return this;
148
+ };
149
+
150
+ // alias used for reserved events (protected method)
151
+ Emitter.prototype.emitReserved = Emitter.prototype.emit;
152
+
153
+ /**
154
+ * Return array of callbacks for `event`.
155
+ *
156
+ * @param {String} event
157
+ * @return {Array}
158
+ * @api public
159
+ */
160
+
161
+ Emitter.prototype.listeners = function(event){
162
+ this._callbacks = this._callbacks || {};
163
+ return this._callbacks['$' + event] || [];
164
+ };
165
+
166
+ /**
167
+ * Check if this emitter has `event` handlers.
168
+ *
169
+ * @param {String} event
170
+ * @return {Boolean}
171
+ * @api public
172
+ */
173
+
174
+ Emitter.prototype.hasListeners = function(event){
175
+ return !! this.listeners(event).length;
176
+ };
node_modules/@socket.io/component-emitter/index.mjs ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Initialize a new `Emitter`.
3
+ *
4
+ * @api public
5
+ */
6
+
7
+ export function Emitter(obj) {
8
+ if (obj) return mixin(obj);
9
+ }
10
+
11
+ /**
12
+ * Mixin the emitter properties.
13
+ *
14
+ * @param {Object} obj
15
+ * @return {Object}
16
+ * @api private
17
+ */
18
+
19
+ function mixin(obj) {
20
+ for (var key in Emitter.prototype) {
21
+ obj[key] = Emitter.prototype[key];
22
+ }
23
+ return obj;
24
+ }
25
+
26
+ /**
27
+ * Listen on the given `event` with `fn`.
28
+ *
29
+ * @param {String} event
30
+ * @param {Function} fn
31
+ * @return {Emitter}
32
+ * @api public
33
+ */
34
+
35
+ Emitter.prototype.on =
36
+ Emitter.prototype.addEventListener = function(event, fn){
37
+ this._callbacks = this._callbacks || {};
38
+ (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
39
+ .push(fn);
40
+ return this;
41
+ };
42
+
43
+ /**
44
+ * Adds an `event` listener that will be invoked a single
45
+ * time then automatically removed.
46
+ *
47
+ * @param {String} event
48
+ * @param {Function} fn
49
+ * @return {Emitter}
50
+ * @api public
51
+ */
52
+
53
+ Emitter.prototype.once = function(event, fn){
54
+ function on() {
55
+ this.off(event, on);
56
+ fn.apply(this, arguments);
57
+ }
58
+
59
+ on.fn = fn;
60
+ this.on(event, on);
61
+ return this;
62
+ };
63
+
64
+ /**
65
+ * Remove the given callback for `event` or all
66
+ * registered callbacks.
67
+ *
68
+ * @param {String} event
69
+ * @param {Function} fn
70
+ * @return {Emitter}
71
+ * @api public
72
+ */
73
+
74
+ Emitter.prototype.off =
75
+ Emitter.prototype.removeListener =
76
+ Emitter.prototype.removeAllListeners =
77
+ Emitter.prototype.removeEventListener = function(event, fn){
78
+ this._callbacks = this._callbacks || {};
79
+
80
+ // all
81
+ if (0 == arguments.length) {
82
+ this._callbacks = {};
83
+ return this;
84
+ }
85
+
86
+ // specific event
87
+ var callbacks = this._callbacks['$' + event];
88
+ if (!callbacks) return this;
89
+
90
+ // remove all handlers
91
+ if (1 == arguments.length) {
92
+ delete this._callbacks['$' + event];
93
+ return this;
94
+ }
95
+
96
+ // remove specific handler
97
+ var cb;
98
+ for (var i = 0; i < callbacks.length; i++) {
99
+ cb = callbacks[i];
100
+ if (cb === fn || cb.fn === fn) {
101
+ callbacks.splice(i, 1);
102
+ break;
103
+ }
104
+ }
105
+
106
+ // Remove event specific arrays for event types that no
107
+ // one is subscribed for to avoid memory leak.
108
+ if (callbacks.length === 0) {
109
+ delete this._callbacks['$' + event];
110
+ }
111
+
112
+ return this;
113
+ };
114
+
115
+ /**
116
+ * Emit `event` with the given args.
117
+ *
118
+ * @param {String} event
119
+ * @param {Mixed} ...
120
+ * @return {Emitter}
121
+ */
122
+
123
+ Emitter.prototype.emit = function(event){
124
+ this._callbacks = this._callbacks || {};
125
+
126
+ var args = new Array(arguments.length - 1)
127
+ , callbacks = this._callbacks['$' + event];
128
+
129
+ for (var i = 1; i < arguments.length; i++) {
130
+ args[i - 1] = arguments[i];
131
+ }
132
+
133
+ if (callbacks) {
134
+ callbacks = callbacks.slice(0);
135
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
136
+ callbacks[i].apply(this, args);
137
+ }
138
+ }
139
+
140
+ return this;
141
+ };
142
+
143
+ // alias used for reserved events (protected method)
144
+ Emitter.prototype.emitReserved = Emitter.prototype.emit;
145
+
146
+ /**
147
+ * Return array of callbacks for `event`.
148
+ *
149
+ * @param {String} event
150
+ * @return {Array}
151
+ * @api public
152
+ */
153
+
154
+ Emitter.prototype.listeners = function(event){
155
+ this._callbacks = this._callbacks || {};
156
+ return this._callbacks['$' + event] || [];
157
+ };
158
+
159
+ /**
160
+ * Check if this emitter has `event` handlers.
161
+ *
162
+ * @param {String} event
163
+ * @return {Boolean}
164
+ * @api public
165
+ */
166
+
167
+ Emitter.prototype.hasListeners = function(event){
168
+ return !! this.listeners(event).length;
169
+ };
node_modules/@socket.io/component-emitter/package.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from": "@socket.io/component-emitter@~3.1.0",
3
+ "_id": "@socket.io/[email protected]",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==",
6
+ "_location": "/@socket.io/component-emitter",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "@socket.io/component-emitter@~3.1.0",
12
+ "name": "@socket.io/component-emitter",
13
+ "escapedName": "@socket.io%2fcomponent-emitter",
14
+ "scope": "@socket.io",
15
+ "rawSpec": "~3.1.0",
16
+ "saveSpec": null,
17
+ "fetchSpec": "~3.1.0"
18
+ },
19
+ "_requiredBy": [
20
+ "/socket.io-parser"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
23
+ "_shasum": "96116f2a912e0c02817345b3c10751069920d553",
24
+ "_spec": "@socket.io/component-emitter@~3.1.0",
25
+ "_where": "/Users/sylvainfiloni/Documents/HF spaces/Docker test/controlnet anim/controlnet-animation-doodle/node_modules/socket.io-parser",
26
+ "bugs": {
27
+ "url": "https://github.com/socketio/emitter/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "component": {
31
+ "scripts": {
32
+ "emitter/index.js": "index.js"
33
+ }
34
+ },
35
+ "deprecated": false,
36
+ "description": "Event emitter",
37
+ "devDependencies": {
38
+ "mocha": "*",
39
+ "should": "*"
40
+ },
41
+ "files": [
42
+ "index.js",
43
+ "index.mjs",
44
+ "index.d.ts",
45
+ "LICENSE"
46
+ ],
47
+ "homepage": "https://github.com/socketio/emitter#readme",
48
+ "license": "MIT",
49
+ "main": "index.js",
50
+ "module": "index.mjs",
51
+ "name": "@socket.io/component-emitter",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/socketio/emitter.git"
55
+ },
56
+ "scripts": {
57
+ "test": "make test"
58
+ },
59
+ "types": "index.d.ts",
60
+ "version": "3.1.0"
61
+ }
node_modules/@types/cookie/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
node_modules/@types/cookie/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Installation
2
+ > `npm install --save @types/cookie`
3
+
4
+ # Summary
5
+ This package contains type definitions for cookie (https://github.com/jshttp/cookie).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie.
9
+
10
+ ### Additional Details
11
+ * Last updated: Tue, 06 Jul 2021 20:32:30 GMT
12
+ * Dependencies: none
13
+ * Global values: none
14
+
15
+ # Credits
16
+ These definitions were written by [Pine Mizune](https://github.com/pine), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
node_modules/@types/cookie/index.d.ts ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Type definitions for cookie 0.4
2
+ // Project: https://github.com/jshttp/cookie
3
+ // Definitions by: Pine Mizune <https://github.com/pine>
4
+ // Piotr Błażejewicz <https://github.com/peterblazejewicz>
5
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
+
7
+ /**
8
+ * Basic HTTP cookie parser and serializer for HTTP servers.
9
+ */
10
+
11
+ /**
12
+ * Additional serialization options
13
+ */
14
+ export interface CookieSerializeOptions {
15
+ /**
16
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
17
+ * domain is set, and most clients will consider the cookie to apply to only
18
+ * the current domain.
19
+ */
20
+ domain?: string | undefined;
21
+
22
+ /**
23
+ * Specifies a function that will be used to encode a cookie's value. Since
24
+ * value of a cookie has a limited character set (and must be a simple
25
+ * string), this function can be used to encode a value into a string suited
26
+ * for a cookie's value.
27
+ *
28
+ * The default function is the global `encodeURIComponent`, which will
29
+ * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
30
+ * any that fall outside of the cookie range.
31
+ */
32
+ encode?(value: string): string;
33
+
34
+ /**
35
+ * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,
36
+ * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
37
+ * it on a condition like exiting a web browser application.
38
+ *
39
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
40
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
41
+ * possible not all clients by obey this, so if both are set, they should
42
+ * point to the same date and time.
43
+ */
44
+ expires?: Date | undefined;
45
+ /**
46
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
47
+ * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
48
+ * default, the `HttpOnly` attribute is not set.
49
+ *
50
+ * *Note* be careful when setting this to true, as compliant clients will
51
+ * not allow client-side JavaScript to see the cookie in `document.cookie`.
52
+ */
53
+ httpOnly?: boolean | undefined;
54
+ /**
55
+ * Specifies the number (in seconds) to be the value for the `Max-Age`
56
+ * `Set-Cookie` attribute. The given number will be converted to an integer
57
+ * by rounding down. By default, no maximum age is set.
58
+ *
59
+ * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
60
+ * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
61
+ * possible not all clients by obey this, so if both are set, they should
62
+ * point to the same date and time.
63
+ */
64
+ maxAge?: number | undefined;
65
+ /**
66
+ * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
67
+ * By default, the path is considered the "default path".
68
+ */
69
+ path?: string | undefined;
70
+ /**
71
+ * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
72
+ *
73
+ * - `true` will set the `SameSite` attribute to `Strict` for strict same
74
+ * site enforcement.
75
+ * - `false` will not set the `SameSite` attribute.
76
+ * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
77
+ * enforcement.
78
+ * - `'strict'` will set the `SameSite` attribute to Strict for strict same
79
+ * site enforcement.
80
+ * - `'none'` will set the SameSite attribute to None for an explicit
81
+ * cross-site cookie.
82
+ *
83
+ * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
84
+ *
85
+ * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
86
+ */
87
+ sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined;
88
+ /**
89
+ * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
90
+ * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
91
+ *
92
+ * *Note* be careful when setting this to `true`, as compliant clients will
93
+ * not send the cookie back to the server in the future if the browser does
94
+ * not have an HTTPS connection.
95
+ */
96
+ secure?: boolean | undefined;
97
+ }
98
+
99
+ /**
100
+ * Additional parsing options
101
+ */
102
+ export interface CookieParseOptions {
103
+ /**
104
+ * Specifies a function that will be used to decode a cookie's value. Since
105
+ * the value of a cookie has a limited character set (and must be a simple
106
+ * string), this function can be used to decode a previously-encoded cookie
107
+ * value into a JavaScript string or other object.
108
+ *
109
+ * The default function is the global `decodeURIComponent`, which will decode
110
+ * any URL-encoded sequences into their byte representations.
111
+ *
112
+ * *Note* if an error is thrown from this function, the original, non-decoded
113
+ * cookie value will be returned as the cookie's value.
114
+ */
115
+ decode?(value: string): string;
116
+ }
117
+
118
+ /**
119
+ * Parse an HTTP Cookie header string and returning an object of all cookie
120
+ * name-value pairs.
121
+ *
122
+ * @param str the string representing a `Cookie` header value
123
+ * @param [options] object containing parsing options
124
+ */
125
+ export function parse(str: string, options?: CookieParseOptions): { [key: string]: string };
126
+
127
+ /**
128
+ * Serialize a cookie name-value pair into a `Set-Cookie` header string.
129
+ *
130
+ * @param name the name for the cookie
131
+ * @param value value to set the cookie to
132
+ * @param [options] object containing serialization options
133
+ * @throws {TypeError} when `maxAge` options is invalid
134
+ */
135
+ export function serialize(name: string, value: string, options?: CookieSerializeOptions): string;
node_modules/@types/cookie/package.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from": "@types/cookie@^0.4.1",
3
+ "_id": "@types/[email protected]",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==",
6
+ "_location": "/@types/cookie",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "@types/cookie@^0.4.1",
12
+ "name": "@types/cookie",
13
+ "escapedName": "@types%2fcookie",
14
+ "scope": "@types",
15
+ "rawSpec": "^0.4.1",
16
+ "saveSpec": null,
17
+ "fetchSpec": "^0.4.1"
18
+ },
19
+ "_requiredBy": [
20
+ "/engine.io"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
23
+ "_shasum": "bfd02c1f2224567676c1545199f87c3a861d878d",
24
+ "_spec": "@types/cookie@^0.4.1",
25
+ "_where": "/Users/sylvainfiloni/Documents/HF spaces/Docker test/controlnet anim/controlnet-animation-doodle/node_modules/engine.io",
26
+ "bugs": {
27
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "contributors": [
31
+ {
32
+ "name": "Pine Mizune",
33
+ "url": "https://github.com/pine"
34
+ },
35
+ {
36
+ "name": "Piotr Błażejewicz",
37
+ "url": "https://github.com/peterblazejewicz"
38
+ }
39
+ ],
40
+ "dependencies": {},
41
+ "deprecated": false,
42
+ "description": "TypeScript definitions for cookie",
43
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie",
44
+ "license": "MIT",
45
+ "main": "",
46
+ "name": "@types/cookie",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
50
+ "directory": "types/cookie"
51
+ },
52
+ "scripts": {},
53
+ "typeScriptVersion": "3.6",
54
+ "types": "index.d.ts",
55
+ "typesPublisherContentHash": "7d4a6dd505c896319459ae131b5fa8fc0a2ed25552db53dac87946119bb21559",
56
+ "version": "0.4.1"
57
+ }
node_modules/@types/cors/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
node_modules/@types/cors/README.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Installation
2
+ > `npm install --save @types/cors`
3
+
4
+ # Summary
5
+ This package contains type definitions for cors (https://github.com/expressjs/cors/).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors.
9
+ ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors/index.d.ts)
10
+ ````ts
11
+ // Type definitions for cors 2.8
12
+ // Project: https://github.com/expressjs/cors/
13
+ // Definitions by: Alan Plum <https://github.com/pluma>
14
+ // Gaurav Sharma <https://github.com/gtpan77>
15
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
+ // TypeScript Version: 2.3
17
+
18
+ /// <reference types="node" />
19
+
20
+ import { IncomingHttpHeaders } from 'http';
21
+
22
+ type StaticOrigin = boolean | string | RegExp | (boolean | string | RegExp)[];
23
+
24
+ type CustomOrigin = (requestOrigin: string | undefined, callback: (err: Error | null, origin?: StaticOrigin) => void) => void;
25
+
26
+ declare namespace e {
27
+ interface CorsRequest {
28
+ method?: string | undefined;
29
+ headers: IncomingHttpHeaders;
30
+ }
31
+ interface CorsOptions {
32
+ /**
33
+ * @default '*''
34
+ */
35
+ origin?: StaticOrigin | CustomOrigin | undefined;
36
+ /**
37
+ * @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
38
+ */
39
+ methods?: string | string[] | undefined;
40
+ allowedHeaders?: string | string[] | undefined;
41
+ exposedHeaders?: string | string[] | undefined;
42
+ credentials?: boolean | undefined;
43
+ maxAge?: number | undefined;
44
+ /**
45
+ * @default false
46
+ */
47
+ preflightContinue?: boolean | undefined;
48
+ /**
49
+ * @default 204
50
+ */
51
+ optionsSuccessStatus?: number | undefined;
52
+ }
53
+ type CorsOptionsDelegate<T extends CorsRequest = CorsRequest> = (
54
+ req: T,
55
+ callback: (err: Error | null, options?: CorsOptions) => void,
56
+ ) => void;
57
+ }
58
+
59
+ declare function e<T extends e.CorsRequest = e.CorsRequest>(
60
+ options?: e.CorsOptions | e.CorsOptionsDelegate<T>,
61
+ ): (
62
+ req: T,
63
+ res: {
64
+ statusCode?: number | undefined;
65
+ setHeader(key: string, value: string): any;
66
+ end(): any;
67
+ },
68
+ next: (err?: any) => any,
69
+ ) => void;
70
+ export = e;
71
+
72
+ ````
73
+
74
+ ### Additional Details
75
+ * Last updated: Mon, 05 Dec 2022 07:33:01 GMT
76
+ * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
77
+ * Global values: none
78
+
79
+ # Credits
80
+ These definitions were written by [Alan Plum](https://github.com/pluma), and [Gaurav Sharma](https://github.com/gtpan77).
node_modules/@types/cors/index.d.ts ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Type definitions for cors 2.8
2
+ // Project: https://github.com/expressjs/cors/
3
+ // Definitions by: Alan Plum <https://github.com/pluma>
4
+ // Gaurav Sharma <https://github.com/gtpan77>
5
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
+ // TypeScript Version: 2.3
7
+
8
+ /// <reference types="node" />
9
+
10
+ import { IncomingHttpHeaders } from 'http';
11
+
12
+ type StaticOrigin = boolean | string | RegExp | (boolean | string | RegExp)[];
13
+
14
+ type CustomOrigin = (requestOrigin: string | undefined, callback: (err: Error | null, origin?: StaticOrigin) => void) => void;
15
+
16
+ declare namespace e {
17
+ interface CorsRequest {
18
+ method?: string | undefined;
19
+ headers: IncomingHttpHeaders;
20
+ }
21
+ interface CorsOptions {
22
+ /**
23
+ * @default '*''
24
+ */
25
+ origin?: StaticOrigin | CustomOrigin | undefined;
26
+ /**
27
+ * @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
28
+ */
29
+ methods?: string | string[] | undefined;
30
+ allowedHeaders?: string | string[] | undefined;
31
+ exposedHeaders?: string | string[] | undefined;
32
+ credentials?: boolean | undefined;
33
+ maxAge?: number | undefined;
34
+ /**
35
+ * @default false
36
+ */
37
+ preflightContinue?: boolean | undefined;
38
+ /**
39
+ * @default 204
40
+ */
41
+ optionsSuccessStatus?: number | undefined;
42
+ }
43
+ type CorsOptionsDelegate<T extends CorsRequest = CorsRequest> = (
44
+ req: T,
45
+ callback: (err: Error | null, options?: CorsOptions) => void,
46
+ ) => void;
47
+ }
48
+
49
+ declare function e<T extends e.CorsRequest = e.CorsRequest>(
50
+ options?: e.CorsOptions | e.CorsOptionsDelegate<T>,
51
+ ): (
52
+ req: T,
53
+ res: {
54
+ statusCode?: number | undefined;
55
+ setHeader(key: string, value: string): any;
56
+ end(): any;
57
+ },
58
+ next: (err?: any) => any,
59
+ ) => void;
60
+ export = e;
node_modules/@types/cors/package.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from": "@types/cors@^2.8.12",
3
+ "_id": "@types/[email protected]",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
6
+ "_location": "/@types/cors",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "@types/cors@^2.8.12",
12
+ "name": "@types/cors",
13
+ "escapedName": "@types%2fcors",
14
+ "scope": "@types",
15
+ "rawSpec": "^2.8.12",
16
+ "saveSpec": null,
17
+ "fetchSpec": "^2.8.12"
18
+ },
19
+ "_requiredBy": [
20
+ "/engine.io"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
23
+ "_shasum": "b8ade22ba455a1b8cb3b5d3f35910fd204f84f94",
24
+ "_spec": "@types/cors@^2.8.12",
25
+ "_where": "/Users/sylvainfiloni/Documents/HF spaces/Docker test/controlnet anim/controlnet-animation-doodle/node_modules/engine.io",
26
+ "bugs": {
27
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "contributors": [
31
+ {
32
+ "name": "Alan Plum",
33
+ "url": "https://github.com/pluma"
34
+ },
35
+ {
36
+ "name": "Gaurav Sharma",
37
+ "url": "https://github.com/gtpan77"
38
+ }
39
+ ],
40
+ "dependencies": {
41
+ "@types/node": "*"
42
+ },
43
+ "deprecated": false,
44
+ "description": "TypeScript definitions for cors",
45
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors",
46
+ "license": "MIT",
47
+ "main": "",
48
+ "name": "@types/cors",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
52
+ "directory": "types/cors"
53
+ },
54
+ "scripts": {},
55
+ "typeScriptVersion": "4.2",
56
+ "types": "index.d.ts",
57
+ "typesPublisherContentHash": "7979c95081a89c6479dfb9a9a432965c861677edef9443df6d4a871a5db924c4",
58
+ "version": "2.8.13"
59
+ }
node_modules/@types/node/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
node_modules/@types/node/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Installation
2
+ > `npm install --save @types/node`
3
+
4
+ # Summary
5
+ This package contains type definitions for Node.js (https://nodejs.org/).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
+
10
+ ### Additional Details
11
+ * Last updated: Thu, 09 Mar 2023 20:02:36 GMT
12
+ * Dependencies: none
13
+ * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
+
15
+ # Credits
16
+ These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
node_modules/@types/node/assert.d.ts ADDED
@@ -0,0 +1,961 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `assert` module provides a set of assertion functions for verifying
3
+ * invariants.
4
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js)
5
+ */
6
+ declare module 'assert' {
7
+ /**
8
+ * An alias of {@link ok}.
9
+ * @since v0.5.9
10
+ * @param value The input that is checked for being truthy.
11
+ */
12
+ function assert(value: unknown, message?: string | Error): asserts value;
13
+ namespace assert {
14
+ /**
15
+ * Indicates the failure of an assertion. All errors thrown by the `assert` module
16
+ * will be instances of the `AssertionError` class.
17
+ */
18
+ class AssertionError extends Error {
19
+ actual: unknown;
20
+ expected: unknown;
21
+ operator: string;
22
+ generatedMessage: boolean;
23
+ code: 'ERR_ASSERTION';
24
+ constructor(options?: {
25
+ /** If provided, the error message is set to this value. */
26
+ message?: string | undefined;
27
+ /** The `actual` property on the error instance. */
28
+ actual?: unknown | undefined;
29
+ /** The `expected` property on the error instance. */
30
+ expected?: unknown | undefined;
31
+ /** The `operator` property on the error instance. */
32
+ operator?: string | undefined;
33
+ /** If provided, the generated stack trace omits frames before this function. */
34
+ // tslint:disable-next-line:ban-types
35
+ stackStartFn?: Function | undefined;
36
+ });
37
+ }
38
+ /**
39
+ * This feature is currently experimental and behavior might still change.
40
+ * @since v14.2.0, v12.19.0
41
+ * @experimental
42
+ */
43
+ class CallTracker {
44
+ /**
45
+ * The wrapper function is expected to be called exactly `exact` times. If the
46
+ * function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
47
+ * error.
48
+ *
49
+ * ```js
50
+ * import assert from 'assert';
51
+ *
52
+ * // Creates call tracker.
53
+ * const tracker = new assert.CallTracker();
54
+ *
55
+ * function func() {}
56
+ *
57
+ * // Returns a function that wraps func() that must be called exact times
58
+ * // before tracker.verify().
59
+ * const callsfunc = tracker.calls(func);
60
+ * ```
61
+ * @since v14.2.0, v12.19.0
62
+ * @param [fn='A no-op function']
63
+ * @param [exact=1]
64
+ * @return that wraps `fn`.
65
+ */
66
+ calls(exact?: number): () => void;
67
+ calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
68
+ /**
69
+ * Example:
70
+ *
71
+ * ```js
72
+ * import assert from 'node:assert';
73
+ *
74
+ * const tracker = new assert.CallTracker();
75
+ *
76
+ * function func() {}
77
+ * const callsfunc = tracker.calls(func);
78
+ * callsfunc(1, 2, 3);
79
+ *
80
+ * assert.deepStrictEqual(tracker.getCalls(callsfunc),
81
+ * [{ thisArg: this, arguments: [1, 2, 3 ] }]);
82
+ * ```
83
+ *
84
+ * @since v18.8.0, v16.18.0
85
+ * @params fn
86
+ * @returns An Array with the calls to a tracked function.
87
+ */
88
+ getCalls(fn: Function): CallTrackerCall[];
89
+ /**
90
+ * The arrays contains information about the expected and actual number of calls of
91
+ * the functions that have not been called the expected number of times.
92
+ *
93
+ * ```js
94
+ * import assert from 'assert';
95
+ *
96
+ * // Creates call tracker.
97
+ * const tracker = new assert.CallTracker();
98
+ *
99
+ * function func() {}
100
+ *
101
+ * function foo() {}
102
+ *
103
+ * // Returns a function that wraps func() that must be called exact times
104
+ * // before tracker.verify().
105
+ * const callsfunc = tracker.calls(func, 2);
106
+ *
107
+ * // Returns an array containing information on callsfunc()
108
+ * tracker.report();
109
+ * // [
110
+ * // {
111
+ * // message: 'Expected the func function to be executed 2 time(s) but was
112
+ * // executed 0 time(s).',
113
+ * // actual: 0,
114
+ * // expected: 2,
115
+ * // operator: 'func',
116
+ * // stack: stack trace
117
+ * // }
118
+ * // ]
119
+ * ```
120
+ * @since v14.2.0, v12.19.0
121
+ * @return of objects containing information about the wrapper functions returned by `calls`.
122
+ */
123
+ report(): CallTrackerReportInformation[];
124
+ /**
125
+ * Reset calls of the call tracker.
126
+ * If a tracked function is passed as an argument, the calls will be reset for it.
127
+ * If no arguments are passed, all tracked functions will be reset.
128
+ *
129
+ * ```js
130
+ * import assert from 'node:assert';
131
+ *
132
+ * const tracker = new assert.CallTracker();
133
+ *
134
+ * function func() {}
135
+ * const callsfunc = tracker.calls(func);
136
+ *
137
+ * callsfunc();
138
+ * // Tracker was called once
139
+ * tracker.getCalls(callsfunc).length === 1;
140
+ *
141
+ * tracker.reset(callsfunc);
142
+ * tracker.getCalls(callsfunc).length === 0;
143
+ * ```
144
+ *
145
+ * @since v18.8.0, v16.18.0
146
+ * @param fn a tracked function to reset.
147
+ */
148
+ reset(fn?: Function): void;
149
+ /**
150
+ * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
151
+ * have not been called the expected number of times.
152
+ *
153
+ * ```js
154
+ * import assert from 'assert';
155
+ *
156
+ * // Creates call tracker.
157
+ * const tracker = new assert.CallTracker();
158
+ *
159
+ * function func() {}
160
+ *
161
+ * // Returns a function that wraps func() that must be called exact times
162
+ * // before tracker.verify().
163
+ * const callsfunc = tracker.calls(func, 2);
164
+ *
165
+ * callsfunc();
166
+ *
167
+ * // Will throw an error since callsfunc() was only called once.
168
+ * tracker.verify();
169
+ * ```
170
+ * @since v14.2.0, v12.19.0
171
+ */
172
+ verify(): void;
173
+ }
174
+ interface CallTrackerCall {
175
+ thisArg: object;
176
+ arguments: unknown[];
177
+ }
178
+ interface CallTrackerReportInformation {
179
+ message: string;
180
+ /** The actual number of times the function was called. */
181
+ actual: number;
182
+ /** The number of times the function was expected to be called. */
183
+ expected: number;
184
+ /** The name of the function that is wrapped. */
185
+ operator: string;
186
+ /** A stack trace of the function. */
187
+ stack: object;
188
+ }
189
+ type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
190
+ /**
191
+ * Throws an `AssertionError` with the provided error message or a default
192
+ * error message. If the `message` parameter is an instance of an `Error` then
193
+ * it will be thrown instead of the `AssertionError`.
194
+ *
195
+ * ```js
196
+ * import assert from 'assert/strict';
197
+ *
198
+ * assert.fail();
199
+ * // AssertionError [ERR_ASSERTION]: Failed
200
+ *
201
+ * assert.fail('boom');
202
+ * // AssertionError [ERR_ASSERTION]: boom
203
+ *
204
+ * assert.fail(new TypeError('need array'));
205
+ * // TypeError: need array
206
+ * ```
207
+ *
208
+ * Using `assert.fail()` with more than two arguments is possible but deprecated.
209
+ * See below for further details.
210
+ * @since v0.1.21
211
+ * @param [message='Failed']
212
+ */
213
+ function fail(message?: string | Error): never;
214
+ /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
215
+ function fail(
216
+ actual: unknown,
217
+ expected: unknown,
218
+ message?: string | Error,
219
+ operator?: string,
220
+ // tslint:disable-next-line:ban-types
221
+ stackStartFn?: Function
222
+ ): never;
223
+ /**
224
+ * Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
225
+ *
226
+ * If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
227
+ * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
228
+ * If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
229
+ *
230
+ * Be aware that in the `repl` the error message will be different to the one
231
+ * thrown in a file! See below for further details.
232
+ *
233
+ * ```js
234
+ * import assert from 'assert/strict';
235
+ *
236
+ * assert.ok(true);
237
+ * // OK
238
+ * assert.ok(1);
239
+ * // OK
240
+ *
241
+ * assert.ok();
242
+ * // AssertionError: No value argument passed to `assert.ok()`
243
+ *
244
+ * assert.ok(false, 'it\'s false');
245
+ * // AssertionError: it's false
246
+ *
247
+ * // In the repl:
248
+ * assert.ok(typeof 123 === 'string');
249
+ * // AssertionError: false == true
250
+ *
251
+ * // In a file (e.g. test.js):
252
+ * assert.ok(typeof 123 === 'string');
253
+ * // AssertionError: The expression evaluated to a falsy value:
254
+ * //
255
+ * // assert.ok(typeof 123 === 'string')
256
+ *
257
+ * assert.ok(false);
258
+ * // AssertionError: The expression evaluated to a falsy value:
259
+ * //
260
+ * // assert.ok(false)
261
+ *
262
+ * assert.ok(0);
263
+ * // AssertionError: The expression evaluated to a falsy value:
264
+ * //
265
+ * // assert.ok(0)
266
+ * ```
267
+ *
268
+ * ```js
269
+ * import assert from 'assert/strict';
270
+ *
271
+ * // Using `assert()` works the same:
272
+ * assert(0);
273
+ * // AssertionError: The expression evaluated to a falsy value:
274
+ * //
275
+ * // assert(0)
276
+ * ```
277
+ * @since v0.1.21
278
+ */
279
+ function ok(value: unknown, message?: string | Error): asserts value;
280
+ /**
281
+ * **Strict assertion mode**
282
+ *
283
+ * An alias of {@link strictEqual}.
284
+ *
285
+ * **Legacy assertion mode**
286
+ *
287
+ * > Stability: 3 - Legacy: Use {@link strictEqual} instead.
288
+ *
289
+ * Tests shallow, coercive equality between the `actual` and `expected` parameters
290
+ * using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
291
+ * and treated as being identical if both sides are `NaN`.
292
+ *
293
+ * ```js
294
+ * import assert from 'assert';
295
+ *
296
+ * assert.equal(1, 1);
297
+ * // OK, 1 == 1
298
+ * assert.equal(1, '1');
299
+ * // OK, 1 == '1'
300
+ * assert.equal(NaN, NaN);
301
+ * // OK
302
+ *
303
+ * assert.equal(1, 2);
304
+ * // AssertionError: 1 == 2
305
+ * assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
306
+ * // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
307
+ * ```
308
+ *
309
+ * If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
310
+ * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
311
+ * @since v0.1.21
312
+ */
313
+ function equal(actual: unknown, expected: unknown, message?: string | Error): void;
314
+ /**
315
+ * **Strict assertion mode**
316
+ *
317
+ * An alias of {@link notStrictEqual}.
318
+ *
319
+ * **Legacy assertion mode**
320
+ *
321
+ * > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
322
+ *
323
+ * Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
324
+ * specially handled and treated as being identical if both sides are `NaN`.
325
+ *
326
+ * ```js
327
+ * import assert from 'assert';
328
+ *
329
+ * assert.notEqual(1, 2);
330
+ * // OK
331
+ *
332
+ * assert.notEqual(1, 1);
333
+ * // AssertionError: 1 != 1
334
+ *
335
+ * assert.notEqual(1, '1');
336
+ * // AssertionError: 1 != '1'
337
+ * ```
338
+ *
339
+ * If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
340
+ * message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
341
+ * @since v0.1.21
342
+ */
343
+ function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
344
+ /**
345
+ * **Strict assertion mode**
346
+ *
347
+ * An alias of {@link deepStrictEqual}.
348
+ *
349
+ * **Legacy assertion mode**
350
+ *
351
+ * > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
352
+ *
353
+ * Tests for deep equality between the `actual` and `expected` parameters. Consider
354
+ * using {@link deepStrictEqual} instead. {@link deepEqual} can have
355
+ * surprising results.
356
+ *
357
+ * _Deep equality_ means that the enumerable "own" properties of child objects
358
+ * are also recursively evaluated by the following rules.
359
+ * @since v0.1.21
360
+ */
361
+ function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
362
+ /**
363
+ * **Strict assertion mode**
364
+ *
365
+ * An alias of {@link notDeepStrictEqual}.
366
+ *
367
+ * **Legacy assertion mode**
368
+ *
369
+ * > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
370
+ *
371
+ * Tests for any deep inequality. Opposite of {@link deepEqual}.
372
+ *
373
+ * ```js
374
+ * import assert from 'assert';
375
+ *
376
+ * const obj1 = {
377
+ * a: {
378
+ * b: 1
379
+ * }
380
+ * };
381
+ * const obj2 = {
382
+ * a: {
383
+ * b: 2
384
+ * }
385
+ * };
386
+ * const obj3 = {
387
+ * a: {
388
+ * b: 1
389
+ * }
390
+ * };
391
+ * const obj4 = Object.create(obj1);
392
+ *
393
+ * assert.notDeepEqual(obj1, obj1);
394
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
395
+ *
396
+ * assert.notDeepEqual(obj1, obj2);
397
+ * // OK
398
+ *
399
+ * assert.notDeepEqual(obj1, obj3);
400
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
401
+ *
402
+ * assert.notDeepEqual(obj1, obj4);
403
+ * // OK
404
+ * ```
405
+ *
406
+ * If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
407
+ * error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
408
+ * instead of the `AssertionError`.
409
+ * @since v0.1.21
410
+ */
411
+ function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
412
+ /**
413
+ * Tests strict equality between the `actual` and `expected` parameters as
414
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
415
+ *
416
+ * ```js
417
+ * import assert from 'assert/strict';
418
+ *
419
+ * assert.strictEqual(1, 2);
420
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
421
+ * //
422
+ * // 1 !== 2
423
+ *
424
+ * assert.strictEqual(1, 1);
425
+ * // OK
426
+ *
427
+ * assert.strictEqual('Hello foobar', 'Hello World!');
428
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
429
+ * // + actual - expected
430
+ * //
431
+ * // + 'Hello foobar'
432
+ * // - 'Hello World!'
433
+ * // ^
434
+ *
435
+ * const apples = 1;
436
+ * const oranges = 2;
437
+ * assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
438
+ * // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
439
+ *
440
+ * assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
441
+ * // TypeError: Inputs are not identical
442
+ * ```
443
+ *
444
+ * If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
445
+ * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
446
+ * instead of the `AssertionError`.
447
+ * @since v0.1.21
448
+ */
449
+ function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
450
+ /**
451
+ * Tests strict inequality between the `actual` and `expected` parameters as
452
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
453
+ *
454
+ * ```js
455
+ * import assert from 'assert/strict';
456
+ *
457
+ * assert.notStrictEqual(1, 2);
458
+ * // OK
459
+ *
460
+ * assert.notStrictEqual(1, 1);
461
+ * // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
462
+ * //
463
+ * // 1
464
+ *
465
+ * assert.notStrictEqual(1, '1');
466
+ * // OK
467
+ * ```
468
+ *
469
+ * If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
470
+ * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
471
+ * instead of the `AssertionError`.
472
+ * @since v0.1.21
473
+ */
474
+ function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
475
+ /**
476
+ * Tests for deep equality between the `actual` and `expected` parameters.
477
+ * "Deep" equality means that the enumerable "own" properties of child objects
478
+ * are recursively evaluated also by the following rules.
479
+ * @since v1.2.0
480
+ */
481
+ function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
482
+ /**
483
+ * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
484
+ *
485
+ * ```js
486
+ * import assert from 'assert/strict';
487
+ *
488
+ * assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
489
+ * // OK
490
+ * ```
491
+ *
492
+ * If the values are deeply and strictly equal, an `AssertionError` is thrown
493
+ * with a `message` property set equal to the value of the `message` parameter. If
494
+ * the `message` parameter is undefined, a default error message is assigned. If
495
+ * the `message` parameter is an instance of an `Error` then it will be thrown
496
+ * instead of the `AssertionError`.
497
+ * @since v1.2.0
498
+ */
499
+ function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
500
+ /**
501
+ * Expects the function `fn` to throw an error.
502
+ *
503
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
504
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
505
+ * a validation object where each property will be tested for strict deep equality,
506
+ * or an instance of error where each property will be tested for strict deep
507
+ * equality including the non-enumerable `message` and `name` properties. When
508
+ * using an object, it is also possible to use a regular expression, when
509
+ * validating against a string property. See below for examples.
510
+ *
511
+ * If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
512
+ * fails.
513
+ *
514
+ * Custom validation object/error instance:
515
+ *
516
+ * ```js
517
+ * import assert from 'assert/strict';
518
+ *
519
+ * const err = new TypeError('Wrong value');
520
+ * err.code = 404;
521
+ * err.foo = 'bar';
522
+ * err.info = {
523
+ * nested: true,
524
+ * baz: 'text'
525
+ * };
526
+ * err.reg = /abc/i;
527
+ *
528
+ * assert.throws(
529
+ * () => {
530
+ * throw err;
531
+ * },
532
+ * {
533
+ * name: 'TypeError',
534
+ * message: 'Wrong value',
535
+ * info: {
536
+ * nested: true,
537
+ * baz: 'text'
538
+ * }
539
+ * // Only properties on the validation object will be tested for.
540
+ * // Using nested objects requires all properties to be present. Otherwise
541
+ * // the validation is going to fail.
542
+ * }
543
+ * );
544
+ *
545
+ * // Using regular expressions to validate error properties:
546
+ * throws(
547
+ * () => {
548
+ * throw err;
549
+ * },
550
+ * {
551
+ * // The `name` and `message` properties are strings and using regular
552
+ * // expressions on those will match against the string. If they fail, an
553
+ * // error is thrown.
554
+ * name: /^TypeError$/,
555
+ * message: /Wrong/,
556
+ * foo: 'bar',
557
+ * info: {
558
+ * nested: true,
559
+ * // It is not possible to use regular expressions for nested properties!
560
+ * baz: 'text'
561
+ * },
562
+ * // The `reg` property contains a regular expression and only if the
563
+ * // validation object contains an identical regular expression, it is going
564
+ * // to pass.
565
+ * reg: /abc/i
566
+ * }
567
+ * );
568
+ *
569
+ * // Fails due to the different `message` and `name` properties:
570
+ * throws(
571
+ * () => {
572
+ * const otherErr = new Error('Not found');
573
+ * // Copy all enumerable properties from `err` to `otherErr`.
574
+ * for (const [key, value] of Object.entries(err)) {
575
+ * otherErr[key] = value;
576
+ * }
577
+ * throw otherErr;
578
+ * },
579
+ * // The error's `message` and `name` properties will also be checked when using
580
+ * // an error as validation object.
581
+ * err
582
+ * );
583
+ * ```
584
+ *
585
+ * Validate instanceof using constructor:
586
+ *
587
+ * ```js
588
+ * import assert from 'assert/strict';
589
+ *
590
+ * assert.throws(
591
+ * () => {
592
+ * throw new Error('Wrong value');
593
+ * },
594
+ * Error
595
+ * );
596
+ * ```
597
+ *
598
+ * Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
599
+ *
600
+ * Using a regular expression runs `.toString` on the error object, and will
601
+ * therefore also include the error name.
602
+ *
603
+ * ```js
604
+ * import assert from 'assert/strict';
605
+ *
606
+ * assert.throws(
607
+ * () => {
608
+ * throw new Error('Wrong value');
609
+ * },
610
+ * /^Error: Wrong value$/
611
+ * );
612
+ * ```
613
+ *
614
+ * Custom error validation:
615
+ *
616
+ * The function must return `true` to indicate all internal validations passed.
617
+ * It will otherwise fail with an `AssertionError`.
618
+ *
619
+ * ```js
620
+ * import assert from 'assert/strict';
621
+ *
622
+ * assert.throws(
623
+ * () => {
624
+ * throw new Error('Wrong value');
625
+ * },
626
+ * (err) => {
627
+ * assert(err instanceof Error);
628
+ * assert(/value/.test(err));
629
+ * // Avoid returning anything from validation functions besides `true`.
630
+ * // Otherwise, it's not clear what part of the validation failed. Instead,
631
+ * // throw an error about the specific validation that failed (as done in this
632
+ * // example) and add as much helpful debugging information to that error as
633
+ * // possible.
634
+ * return true;
635
+ * },
636
+ * 'unexpected error'
637
+ * );
638
+ * ```
639
+ *
640
+ * `error` cannot be a string. If a string is provided as the second
641
+ * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
642
+ * message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
643
+ * a string as the second argument gets considered:
644
+ *
645
+ * ```js
646
+ * import assert from 'assert/strict';
647
+ *
648
+ * function throwingFirst() {
649
+ * throw new Error('First');
650
+ * }
651
+ *
652
+ * function throwingSecond() {
653
+ * throw new Error('Second');
654
+ * }
655
+ *
656
+ * function notThrowing() {}
657
+ *
658
+ * // The second argument is a string and the input function threw an Error.
659
+ * // The first case will not throw as it does not match for the error message
660
+ * // thrown by the input function!
661
+ * assert.throws(throwingFirst, 'Second');
662
+ * // In the next example the message has no benefit over the message from the
663
+ * // error and since it is not clear if the user intended to actually match
664
+ * // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
665
+ * assert.throws(throwingSecond, 'Second');
666
+ * // TypeError [ERR_AMBIGUOUS_ARGUMENT]
667
+ *
668
+ * // The string is only used (as message) in case the function does not throw:
669
+ * assert.throws(notThrowing, 'Second');
670
+ * // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
671
+ *
672
+ * // If it was intended to match for the error message do this instead:
673
+ * // It does not throw because the error messages match.
674
+ * assert.throws(throwingSecond, /Second$/);
675
+ *
676
+ * // If the error message does not match, an AssertionError is thrown.
677
+ * assert.throws(throwingFirst, /Second$/);
678
+ * // AssertionError [ERR_ASSERTION]
679
+ * ```
680
+ *
681
+ * Due to the confusing error-prone notation, avoid a string as the second
682
+ * argument.
683
+ * @since v0.1.21
684
+ */
685
+ function throws(block: () => unknown, message?: string | Error): void;
686
+ function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
687
+ /**
688
+ * Asserts that the function `fn` does not throw an error.
689
+ *
690
+ * Using `assert.doesNotThrow()` is actually not useful because there
691
+ * is no benefit in catching an error and then rethrowing it. Instead, consider
692
+ * adding a comment next to the specific code path that should not throw and keep
693
+ * error messages as expressive as possible.
694
+ *
695
+ * When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
696
+ *
697
+ * If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
698
+ * different type, or if the `error` parameter is undefined, the error is
699
+ * propagated back to the caller.
700
+ *
701
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
702
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
703
+ * function. See {@link throws} for more details.
704
+ *
705
+ * The following, for instance, will throw the `TypeError` because there is no
706
+ * matching error type in the assertion:
707
+ *
708
+ * ```js
709
+ * import assert from 'assert/strict';
710
+ *
711
+ * assert.doesNotThrow(
712
+ * () => {
713
+ * throw new TypeError('Wrong value');
714
+ * },
715
+ * SyntaxError
716
+ * );
717
+ * ```
718
+ *
719
+ * However, the following will result in an `AssertionError` with the message
720
+ * 'Got unwanted exception...':
721
+ *
722
+ * ```js
723
+ * import assert from 'assert/strict';
724
+ *
725
+ * assert.doesNotThrow(
726
+ * () => {
727
+ * throw new TypeError('Wrong value');
728
+ * },
729
+ * TypeError
730
+ * );
731
+ * ```
732
+ *
733
+ * If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
734
+ *
735
+ * ```js
736
+ * import assert from 'assert/strict';
737
+ *
738
+ * assert.doesNotThrow(
739
+ * () => {
740
+ * throw new TypeError('Wrong value');
741
+ * },
742
+ * /Wrong value/,
743
+ * 'Whoops'
744
+ * );
745
+ * // Throws: AssertionError: Got unwanted exception: Whoops
746
+ * ```
747
+ * @since v0.1.21
748
+ */
749
+ function doesNotThrow(block: () => unknown, message?: string | Error): void;
750
+ function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
751
+ /**
752
+ * Throws `value` if `value` is not `undefined` or `null`. This is useful when
753
+ * testing the `error` argument in callbacks. The stack trace contains all frames
754
+ * from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
755
+ *
756
+ * ```js
757
+ * import assert from 'assert/strict';
758
+ *
759
+ * assert.ifError(null);
760
+ * // OK
761
+ * assert.ifError(0);
762
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
763
+ * assert.ifError('error');
764
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
765
+ * assert.ifError(new Error());
766
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
767
+ *
768
+ * // Create some random error frames.
769
+ * let err;
770
+ * (function errorFrame() {
771
+ * err = new Error('test error');
772
+ * })();
773
+ *
774
+ * (function ifErrorFrame() {
775
+ * assert.ifError(err);
776
+ * })();
777
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
778
+ * // at ifErrorFrame
779
+ * // at errorFrame
780
+ * ```
781
+ * @since v0.1.97
782
+ */
783
+ function ifError(value: unknown): asserts value is null | undefined;
784
+ /**
785
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
786
+ * calls the function and awaits the returned promise to complete. It will then
787
+ * check that the promise is rejected.
788
+ *
789
+ * If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
790
+ * function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
791
+ * handler is skipped.
792
+ *
793
+ * Besides the async nature to await the completion behaves identically to {@link throws}.
794
+ *
795
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
796
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
797
+ * an object where each property will be tested for, or an instance of error where
798
+ * each property will be tested for including the non-enumerable `message` and`name` properties.
799
+ *
800
+ * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
801
+ *
802
+ * ```js
803
+ * import assert from 'assert/strict';
804
+ *
805
+ * await assert.rejects(
806
+ * async () => {
807
+ * throw new TypeError('Wrong value');
808
+ * },
809
+ * {
810
+ * name: 'TypeError',
811
+ * message: 'Wrong value'
812
+ * }
813
+ * );
814
+ * ```
815
+ *
816
+ * ```js
817
+ * import assert from 'assert/strict';
818
+ *
819
+ * await assert.rejects(
820
+ * async () => {
821
+ * throw new TypeError('Wrong value');
822
+ * },
823
+ * (err) => {
824
+ * assert.strictEqual(err.name, 'TypeError');
825
+ * assert.strictEqual(err.message, 'Wrong value');
826
+ * return true;
827
+ * }
828
+ * );
829
+ * ```
830
+ *
831
+ * ```js
832
+ * import assert from 'assert/strict';
833
+ *
834
+ * assert.rejects(
835
+ * Promise.reject(new Error('Wrong value')),
836
+ * Error
837
+ * ).then(() => {
838
+ * // ...
839
+ * });
840
+ * ```
841
+ *
842
+ * `error` cannot be a string. If a string is provided as the second
843
+ * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
844
+ * example in {@link throws} carefully if using a string as the second
845
+ * argument gets considered.
846
+ * @since v10.0.0
847
+ */
848
+ function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
849
+ function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
850
+ /**
851
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
852
+ * calls the function and awaits the returned promise to complete. It will then
853
+ * check that the promise is not rejected.
854
+ *
855
+ * If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
856
+ * the function does not return a promise, `assert.doesNotReject()` will return a
857
+ * rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
858
+ * the error handler is skipped.
859
+ *
860
+ * Using `assert.doesNotReject()` is actually not useful because there is little
861
+ * benefit in catching a rejection and then rejecting it again. Instead, consider
862
+ * adding a comment next to the specific code path that should not reject and keep
863
+ * error messages as expressive as possible.
864
+ *
865
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
866
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
867
+ * function. See {@link throws} for more details.
868
+ *
869
+ * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
870
+ *
871
+ * ```js
872
+ * import assert from 'assert/strict';
873
+ *
874
+ * await assert.doesNotReject(
875
+ * async () => {
876
+ * throw new TypeError('Wrong value');
877
+ * },
878
+ * SyntaxError
879
+ * );
880
+ * ```
881
+ *
882
+ * ```js
883
+ * import assert from 'assert/strict';
884
+ *
885
+ * assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
886
+ * .then(() => {
887
+ * // ...
888
+ * });
889
+ * ```
890
+ * @since v10.0.0
891
+ */
892
+ function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
893
+ function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
894
+ /**
895
+ * Expects the `string` input to match the regular expression.
896
+ *
897
+ * ```js
898
+ * import assert from 'assert/strict';
899
+ *
900
+ * assert.match('I will fail', /pass/);
901
+ * // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
902
+ *
903
+ * assert.match(123, /pass/);
904
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
905
+ *
906
+ * assert.match('I will pass', /pass/);
907
+ * // OK
908
+ * ```
909
+ *
910
+ * If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
911
+ * to the value of the `message` parameter. If the `message` parameter is
912
+ * undefined, a default error message is assigned. If the `message` parameter is an
913
+ * instance of an `Error` then it will be thrown instead of the `AssertionError`.
914
+ * @since v13.6.0, v12.16.0
915
+ */
916
+ function match(value: string, regExp: RegExp, message?: string | Error): void;
917
+ /**
918
+ * Expects the `string` input not to match the regular expression.
919
+ *
920
+ * ```js
921
+ * import assert from 'assert/strict';
922
+ *
923
+ * assert.doesNotMatch('I will fail', /fail/);
924
+ * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
925
+ *
926
+ * assert.doesNotMatch(123, /pass/);
927
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
928
+ *
929
+ * assert.doesNotMatch('I will pass', /different/);
930
+ * // OK
931
+ * ```
932
+ *
933
+ * If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
934
+ * to the value of the `message` parameter. If the `message` parameter is
935
+ * undefined, a default error message is assigned. If the `message` parameter is an
936
+ * instance of an `Error` then it will be thrown instead of the `AssertionError`.
937
+ * @since v13.6.0, v12.16.0
938
+ */
939
+ function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
940
+ const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
941
+ (value: unknown, message?: string | Error): asserts value;
942
+ equal: typeof strictEqual;
943
+ notEqual: typeof notStrictEqual;
944
+ deepEqual: typeof deepStrictEqual;
945
+ notDeepEqual: typeof notDeepStrictEqual;
946
+ // Mapped types and assertion functions are incompatible?
947
+ // TS2775: Assertions require every name in the call target
948
+ // to be declared with an explicit type annotation.
949
+ ok: typeof ok;
950
+ strictEqual: typeof strictEqual;
951
+ deepStrictEqual: typeof deepStrictEqual;
952
+ ifError: typeof ifError;
953
+ strict: typeof strict;
954
+ };
955
+ }
956
+ export = assert;
957
+ }
958
+ declare module 'node:assert' {
959
+ import assert = require('assert');
960
+ export = assert;
961
+ }
node_modules/@types/node/assert/strict.d.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ declare module 'assert/strict' {
2
+ import { strict } from 'node:assert';
3
+ export = strict;
4
+ }
5
+ declare module 'node:assert/strict' {
6
+ import { strict } from 'node:assert';
7
+ export = strict;
8
+ }
node_modules/@types/node/async_hooks.d.ts ADDED
@@ -0,0 +1,513 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `async_hooks` module provides an API to track asynchronous resources. It
3
+ * can be accessed using:
4
+ *
5
+ * ```js
6
+ * import async_hooks from 'async_hooks';
7
+ * ```
8
+ * @experimental
9
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js)
10
+ */
11
+ declare module 'async_hooks' {
12
+ /**
13
+ * ```js
14
+ * import { executionAsyncId } from 'async_hooks';
15
+ *
16
+ * console.log(executionAsyncId()); // 1 - bootstrap
17
+ * fs.open(path, 'r', (err, fd) => {
18
+ * console.log(executionAsyncId()); // 6 - open()
19
+ * });
20
+ * ```
21
+ *
22
+ * The ID returned from `executionAsyncId()` is related to execution timing, not
23
+ * causality (which is covered by `triggerAsyncId()`):
24
+ *
25
+ * ```js
26
+ * const server = net.createServer((conn) => {
27
+ * // Returns the ID of the server, not of the new connection, because the
28
+ * // callback runs in the execution scope of the server's MakeCallback().
29
+ * async_hooks.executionAsyncId();
30
+ *
31
+ * }).listen(port, () => {
32
+ * // Returns the ID of a TickObject (process.nextTick()) because all
33
+ * // callbacks passed to .listen() are wrapped in a nextTick().
34
+ * async_hooks.executionAsyncId();
35
+ * });
36
+ * ```
37
+ *
38
+ * Promise contexts may not get precise `executionAsyncIds` by default.
39
+ * See the section on `promise execution tracking`.
40
+ * @since v8.1.0
41
+ * @return The `asyncId` of the current execution context. Useful to track when something calls.
42
+ */
43
+ function executionAsyncId(): number;
44
+ /**
45
+ * Resource objects returned by `executionAsyncResource()` are most often internal
46
+ * Node.js handle objects with undocumented APIs. Using any functions or properties
47
+ * on the object is likely to crash your application and should be avoided.
48
+ *
49
+ * Using `executionAsyncResource()` in the top-level execution context will
50
+ * return an empty object as there is no handle or request object to use,
51
+ * but having an object representing the top-level can be helpful.
52
+ *
53
+ * ```js
54
+ * import { open } from 'fs';
55
+ * import { executionAsyncId, executionAsyncResource } from 'async_hooks';
56
+ *
57
+ * console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
58
+ * open(new URL(import.meta.url), 'r', (err, fd) => {
59
+ * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
60
+ * });
61
+ * ```
62
+ *
63
+ * This can be used to implement continuation local storage without the
64
+ * use of a tracking `Map` to store the metadata:
65
+ *
66
+ * ```js
67
+ * import { createServer } from 'http';
68
+ * import {
69
+ * executionAsyncId,
70
+ * executionAsyncResource,
71
+ * createHook
72
+ * } from 'async_hooks';
73
+ * const sym = Symbol('state'); // Private symbol to avoid pollution
74
+ *
75
+ * createHook({
76
+ * init(asyncId, type, triggerAsyncId, resource) {
77
+ * const cr = executionAsyncResource();
78
+ * if (cr) {
79
+ * resource[sym] = cr[sym];
80
+ * }
81
+ * }
82
+ * }).enable();
83
+ *
84
+ * const server = createServer((req, res) => {
85
+ * executionAsyncResource()[sym] = { state: req.url };
86
+ * setTimeout(function() {
87
+ * res.end(JSON.stringify(executionAsyncResource()[sym]));
88
+ * }, 100);
89
+ * }).listen(3000);
90
+ * ```
91
+ * @since v13.9.0, v12.17.0
92
+ * @return The resource representing the current execution. Useful to store data within the resource.
93
+ */
94
+ function executionAsyncResource(): object;
95
+ /**
96
+ * ```js
97
+ * const server = net.createServer((conn) => {
98
+ * // The resource that caused (or triggered) this callback to be called
99
+ * // was that of the new connection. Thus the return value of triggerAsyncId()
100
+ * // is the asyncId of "conn".
101
+ * async_hooks.triggerAsyncId();
102
+ *
103
+ * }).listen(port, () => {
104
+ * // Even though all callbacks passed to .listen() are wrapped in a nextTick()
105
+ * // the callback itself exists because the call to the server's .listen()
106
+ * // was made. So the return value would be the ID of the server.
107
+ * async_hooks.triggerAsyncId();
108
+ * });
109
+ * ```
110
+ *
111
+ * Promise contexts may not get valid `triggerAsyncId`s by default. See
112
+ * the section on `promise execution tracking`.
113
+ * @return The ID of the resource responsible for calling the callback that is currently being executed.
114
+ */
115
+ function triggerAsyncId(): number;
116
+ interface HookCallbacks {
117
+ /**
118
+ * Called when a class is constructed that has the possibility to emit an asynchronous event.
119
+ * @param asyncId a unique ID for the async resource
120
+ * @param type the type of the async resource
121
+ * @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
122
+ * @param resource reference to the resource representing the async operation, needs to be released during destroy
123
+ */
124
+ init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
125
+ /**
126
+ * When an asynchronous operation is initiated or completes a callback is called to notify the user.
127
+ * The before callback is called just before said callback is executed.
128
+ * @param asyncId the unique identifier assigned to the resource about to execute the callback.
129
+ */
130
+ before?(asyncId: number): void;
131
+ /**
132
+ * Called immediately after the callback specified in before is completed.
133
+ * @param asyncId the unique identifier assigned to the resource which has executed the callback.
134
+ */
135
+ after?(asyncId: number): void;
136
+ /**
137
+ * Called when a promise has resolve() called. This may not be in the same execution id
138
+ * as the promise itself.
139
+ * @param asyncId the unique id for the promise that was resolve()d.
140
+ */
141
+ promiseResolve?(asyncId: number): void;
142
+ /**
143
+ * Called after the resource corresponding to asyncId is destroyed
144
+ * @param asyncId a unique ID for the async resource
145
+ */
146
+ destroy?(asyncId: number): void;
147
+ }
148
+ interface AsyncHook {
149
+ /**
150
+ * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
151
+ */
152
+ enable(): this;
153
+ /**
154
+ * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
155
+ */
156
+ disable(): this;
157
+ }
158
+ /**
159
+ * Registers functions to be called for different lifetime events of each async
160
+ * operation.
161
+ *
162
+ * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
163
+ * respective asynchronous event during a resource's lifetime.
164
+ *
165
+ * All callbacks are optional. For example, if only resource cleanup needs to
166
+ * be tracked, then only the `destroy` callback needs to be passed. The
167
+ * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
168
+ *
169
+ * ```js
170
+ * import { createHook } from 'async_hooks';
171
+ *
172
+ * const asyncHook = createHook({
173
+ * init(asyncId, type, triggerAsyncId, resource) { },
174
+ * destroy(asyncId) { }
175
+ * });
176
+ * ```
177
+ *
178
+ * The callbacks will be inherited via the prototype chain:
179
+ *
180
+ * ```js
181
+ * class MyAsyncCallbacks {
182
+ * init(asyncId, type, triggerAsyncId, resource) { }
183
+ * destroy(asyncId) {}
184
+ * }
185
+ *
186
+ * class MyAddedCallbacks extends MyAsyncCallbacks {
187
+ * before(asyncId) { }
188
+ * after(asyncId) { }
189
+ * }
190
+ *
191
+ * const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
192
+ * ```
193
+ *
194
+ * Because promises are asynchronous resources whose lifecycle is tracked
195
+ * via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
196
+ * @since v8.1.0
197
+ * @param callbacks The `Hook Callbacks` to register
198
+ * @return Instance used for disabling and enabling hooks
199
+ */
200
+ function createHook(callbacks: HookCallbacks): AsyncHook;
201
+ interface AsyncResourceOptions {
202
+ /**
203
+ * The ID of the execution context that created this async event.
204
+ * @default executionAsyncId()
205
+ */
206
+ triggerAsyncId?: number | undefined;
207
+ /**
208
+ * Disables automatic `emitDestroy` when the object is garbage collected.
209
+ * This usually does not need to be set (even if `emitDestroy` is called
210
+ * manually), unless the resource's `asyncId` is retrieved and the
211
+ * sensitive API's `emitDestroy` is called with it.
212
+ * @default false
213
+ */
214
+ requireManualDestroy?: boolean | undefined;
215
+ }
216
+ /**
217
+ * The class `AsyncResource` is designed to be extended by the embedder's async
218
+ * resources. Using this, users can easily trigger the lifetime events of their
219
+ * own resources.
220
+ *
221
+ * The `init` hook will trigger when an `AsyncResource` is instantiated.
222
+ *
223
+ * The following is an overview of the `AsyncResource` API.
224
+ *
225
+ * ```js
226
+ * import { AsyncResource, executionAsyncId } from 'async_hooks';
227
+ *
228
+ * // AsyncResource() is meant to be extended. Instantiating a
229
+ * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
230
+ * // async_hook.executionAsyncId() is used.
231
+ * const asyncResource = new AsyncResource(
232
+ * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
233
+ * );
234
+ *
235
+ * // Run a function in the execution context of the resource. This will
236
+ * // * establish the context of the resource
237
+ * // * trigger the AsyncHooks before callbacks
238
+ * // * call the provided function `fn` with the supplied arguments
239
+ * // * trigger the AsyncHooks after callbacks
240
+ * // * restore the original execution context
241
+ * asyncResource.runInAsyncScope(fn, thisArg, ...args);
242
+ *
243
+ * // Call AsyncHooks destroy callbacks.
244
+ * asyncResource.emitDestroy();
245
+ *
246
+ * // Return the unique ID assigned to the AsyncResource instance.
247
+ * asyncResource.asyncId();
248
+ *
249
+ * // Return the trigger ID for the AsyncResource instance.
250
+ * asyncResource.triggerAsyncId();
251
+ * ```
252
+ */
253
+ class AsyncResource {
254
+ /**
255
+ * AsyncResource() is meant to be extended. Instantiating a
256
+ * new AsyncResource() also triggers init. If triggerAsyncId is omitted then
257
+ * async_hook.executionAsyncId() is used.
258
+ * @param type The type of async event.
259
+ * @param triggerAsyncId The ID of the execution context that created
260
+ * this async event (default: `executionAsyncId()`), or an
261
+ * AsyncResourceOptions object (since v9.3.0)
262
+ */
263
+ constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
264
+ /**
265
+ * Binds the given function to the current execution context.
266
+ *
267
+ * The returned function will have an `asyncResource` property referencing
268
+ * the `AsyncResource` to which the function is bound.
269
+ * @since v14.8.0, v12.19.0
270
+ * @param fn The function to bind to the current execution context.
271
+ * @param type An optional name to associate with the underlying `AsyncResource`.
272
+ */
273
+ static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
274
+ fn: Func,
275
+ type?: string,
276
+ thisArg?: ThisArg
277
+ ): Func & {
278
+ asyncResource: AsyncResource;
279
+ };
280
+ /**
281
+ * Binds the given function to execute to this `AsyncResource`'s scope.
282
+ *
283
+ * The returned function will have an `asyncResource` property referencing
284
+ * the `AsyncResource` to which the function is bound.
285
+ * @since v14.8.0, v12.19.0
286
+ * @param fn The function to bind to the current `AsyncResource`.
287
+ */
288
+ bind<Func extends (...args: any[]) => any>(
289
+ fn: Func
290
+ ): Func & {
291
+ asyncResource: AsyncResource;
292
+ };
293
+ /**
294
+ * Call the provided function with the provided arguments in the execution context
295
+ * of the async resource. This will establish the context, trigger the AsyncHooks
296
+ * before callbacks, call the function, trigger the AsyncHooks after callbacks, and
297
+ * then restore the original execution context.
298
+ * @since v9.6.0
299
+ * @param fn The function to call in the execution context of this async resource.
300
+ * @param thisArg The receiver to be used for the function call.
301
+ * @param args Optional arguments to pass to the function.
302
+ */
303
+ runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
304
+ /**
305
+ * Call all `destroy` hooks. This should only ever be called once. An error will
306
+ * be thrown if it is called more than once. This **must** be manually called. If
307
+ * the resource is left to be collected by the GC then the `destroy` hooks will
308
+ * never be called.
309
+ * @return A reference to `asyncResource`.
310
+ */
311
+ emitDestroy(): this;
312
+ /**
313
+ * @return The unique `asyncId` assigned to the resource.
314
+ */
315
+ asyncId(): number;
316
+ /**
317
+ *
318
+ * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
319
+ */
320
+ triggerAsyncId(): number;
321
+ }
322
+ interface AsyncLocalStorageOptions<T> {
323
+ /**
324
+ * Optional callback invoked before a store is propagated to a new async resource.
325
+ * Returning `true` allows propagation, returning `false` avoids it. Default is to propagate always.
326
+ * @param type The type of async event.
327
+ * @param store The current store.
328
+ * @since v18.13.0
329
+ */
330
+ onPropagate?: ((type: string, store: T) => boolean) | undefined;
331
+ }
332
+ /**
333
+ * This class creates stores that stay coherent through asynchronous operations.
334
+ *
335
+ * While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
336
+ * implementation that involves significant optimizations that are non-obvious to
337
+ * implement.
338
+ *
339
+ * The following example uses `AsyncLocalStorage` to build a simple logger
340
+ * that assigns IDs to incoming HTTP requests and includes them in messages
341
+ * logged within each request.
342
+ *
343
+ * ```js
344
+ * import http from 'http';
345
+ * import { AsyncLocalStorage } from 'async_hooks';
346
+ *
347
+ * const asyncLocalStorage = new AsyncLocalStorage();
348
+ *
349
+ * function logWithId(msg) {
350
+ * const id = asyncLocalStorage.getStore();
351
+ * console.log(`${id !== undefined ? id : '-'}:`, msg);
352
+ * }
353
+ *
354
+ * let idSeq = 0;
355
+ * http.createServer((req, res) => {
356
+ * asyncLocalStorage.run(idSeq++, () => {
357
+ * logWithId('start');
358
+ * // Imagine any chain of async operations here
359
+ * setImmediate(() => {
360
+ * logWithId('finish');
361
+ * res.end();
362
+ * });
363
+ * });
364
+ * }).listen(8080);
365
+ *
366
+ * http.get('http://localhost:8080');
367
+ * http.get('http://localhost:8080');
368
+ * // Prints:
369
+ * // 0: start
370
+ * // 1: start
371
+ * // 0: finish
372
+ * // 1: finish
373
+ * ```
374
+ *
375
+ * Each instance of `AsyncLocalStorage` maintains an independent storage context.
376
+ * Multiple instances can safely exist simultaneously without risk of interfering
377
+ * with each other's data.
378
+ * @since v13.10.0, v12.17.0
379
+ */
380
+ class AsyncLocalStorage<T> {
381
+ constructor(options?: AsyncLocalStorageOptions<T>);
382
+
383
+ /**
384
+ * Disables the instance of `AsyncLocalStorage`. All subsequent calls
385
+ * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
386
+ *
387
+ * When calling `asyncLocalStorage.disable()`, all current contexts linked to the
388
+ * instance will be exited.
389
+ *
390
+ * Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
391
+ * provided by the `asyncLocalStorage`, as those objects are garbage collected
392
+ * along with the corresponding async resources.
393
+ *
394
+ * Use this method when the `asyncLocalStorage` is not in use anymore
395
+ * in the current process.
396
+ * @since v13.10.0, v12.17.0
397
+ * @experimental
398
+ */
399
+ disable(): void;
400
+ /**
401
+ * Returns the current store.
402
+ * If called outside of an asynchronous context initialized by
403
+ * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
404
+ * returns `undefined`.
405
+ * @since v13.10.0, v12.17.0
406
+ */
407
+ getStore(): T | undefined;
408
+ /**
409
+ * Runs a function synchronously within a context and returns its
410
+ * return value. The store is not accessible outside of the callback function.
411
+ * The store is accessible to any asynchronous operations created within the
412
+ * callback.
413
+ *
414
+ * The optional `args` are passed to the callback function.
415
+ *
416
+ * If the callback function throws an error, the error is thrown by `run()` too.
417
+ * The stacktrace is not impacted by this call and the context is exited.
418
+ *
419
+ * Example:
420
+ *
421
+ * ```js
422
+ * const store = { id: 2 };
423
+ * try {
424
+ * asyncLocalStorage.run(store, () => {
425
+ * asyncLocalStorage.getStore(); // Returns the store object
426
+ * setTimeout(() => {
427
+ * asyncLocalStorage.getStore(); // Returns the store object
428
+ * }, 200);
429
+ * throw new Error();
430
+ * });
431
+ * } catch (e) {
432
+ * asyncLocalStorage.getStore(); // Returns undefined
433
+ * // The error will be caught here
434
+ * }
435
+ * ```
436
+ * @since v13.10.0, v12.17.0
437
+ */
438
+ run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
439
+ /**
440
+ * Runs a function synchronously outside of a context and returns its
441
+ * return value. The store is not accessible within the callback function or
442
+ * the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
443
+ *
444
+ * The optional `args` are passed to the callback function.
445
+ *
446
+ * If the callback function throws an error, the error is thrown by `exit()` too.
447
+ * The stacktrace is not impacted by this call and the context is re-entered.
448
+ *
449
+ * Example:
450
+ *
451
+ * ```js
452
+ * // Within a call to run
453
+ * try {
454
+ * asyncLocalStorage.getStore(); // Returns the store object or value
455
+ * asyncLocalStorage.exit(() => {
456
+ * asyncLocalStorage.getStore(); // Returns undefined
457
+ * throw new Error();
458
+ * });
459
+ * } catch (e) {
460
+ * asyncLocalStorage.getStore(); // Returns the same object or value
461
+ * // The error will be caught here
462
+ * }
463
+ * ```
464
+ * @since v13.10.0, v12.17.0
465
+ * @experimental
466
+ */
467
+ exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
468
+ /**
469
+ * Transitions into the context for the remainder of the current
470
+ * synchronous execution and then persists the store through any following
471
+ * asynchronous calls.
472
+ *
473
+ * Example:
474
+ *
475
+ * ```js
476
+ * const store = { id: 1 };
477
+ * // Replaces previous store with the given store object
478
+ * asyncLocalStorage.enterWith(store);
479
+ * asyncLocalStorage.getStore(); // Returns the store object
480
+ * someAsyncOperation(() => {
481
+ * asyncLocalStorage.getStore(); // Returns the same object
482
+ * });
483
+ * ```
484
+ *
485
+ * This transition will continue for the _entire_ synchronous execution.
486
+ * This means that if, for example, the context is entered within an event
487
+ * handler subsequent event handlers will also run within that context unless
488
+ * specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
489
+ * to use the latter method.
490
+ *
491
+ * ```js
492
+ * const store = { id: 1 };
493
+ *
494
+ * emitter.on('my-event', () => {
495
+ * asyncLocalStorage.enterWith(store);
496
+ * });
497
+ * emitter.on('my-event', () => {
498
+ * asyncLocalStorage.getStore(); // Returns the same object
499
+ * });
500
+ *
501
+ * asyncLocalStorage.getStore(); // Returns undefined
502
+ * emitter.emit('my-event');
503
+ * asyncLocalStorage.getStore(); // Returns the same object
504
+ * ```
505
+ * @since v13.11.0, v12.17.0
506
+ * @experimental
507
+ */
508
+ enterWith(store: T): void;
509
+ }
510
+ }
511
+ declare module 'node:async_hooks' {
512
+ export * from 'async_hooks';
513
+ }
node_modules/@types/node/buffer.d.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@types/node/child_process.d.ts ADDED
@@ -0,0 +1,1369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `child_process` module provides the ability to spawn subprocesses in
3
+ * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
4
+ * is primarily provided by the {@link spawn} function:
5
+ *
6
+ * ```js
7
+ * const { spawn } = require('child_process');
8
+ * const ls = spawn('ls', ['-lh', '/usr']);
9
+ *
10
+ * ls.stdout.on('data', (data) => {
11
+ * console.log(`stdout: ${data}`);
12
+ * });
13
+ *
14
+ * ls.stderr.on('data', (data) => {
15
+ * console.error(`stderr: ${data}`);
16
+ * });
17
+ *
18
+ * ls.on('close', (code) => {
19
+ * console.log(`child process exited with code ${code}`);
20
+ * });
21
+ * ```
22
+ *
23
+ * By default, pipes for `stdin`, `stdout`, and `stderr` are established between
24
+ * the parent Node.js process and the spawned subprocess. These pipes have
25
+ * limited (and platform-specific) capacity. If the subprocess writes to
26
+ * stdout in excess of that limit without the output being captured, the
27
+ * subprocess blocks waiting for the pipe buffer to accept more data. This is
28
+ * identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
29
+ *
30
+ * The command lookup is performed using the `options.env.PATH` environment
31
+ * variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
32
+ * used. If `options.env` is set without `PATH`, lookup on Unix is performed
33
+ * on a default search path search of `/usr/bin:/bin` (see your operating system's
34
+ * manual for execvpe/execvp), on Windows the current processes environment
35
+ * variable `PATH` is used.
36
+ *
37
+ * On Windows, environment variables are case-insensitive. Node.js
38
+ * lexicographically sorts the `env` keys and uses the first one that
39
+ * case-insensitively matches. Only first (in lexicographic order) entry will be
40
+ * passed to the subprocess. This might lead to issues on Windows when passing
41
+ * objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`.
42
+ *
43
+ * The {@link spawn} method spawns the child process asynchronously,
44
+ * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
45
+ * the event loop until the spawned process either exits or is terminated.
46
+ *
47
+ * For convenience, the `child_process` module provides a handful of synchronous
48
+ * and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
49
+ * top of {@link spawn} or {@link spawnSync}.
50
+ *
51
+ * * {@link exec}: spawns a shell and runs a command within that
52
+ * shell, passing the `stdout` and `stderr` to a callback function when
53
+ * complete.
54
+ * * {@link execFile}: similar to {@link exec} except
55
+ * that it spawns the command directly without first spawning a shell by
56
+ * default.
57
+ * * {@link fork}: spawns a new Node.js process and invokes a
58
+ * specified module with an IPC communication channel established that allows
59
+ * sending messages between parent and child.
60
+ * * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop.
61
+ * * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop.
62
+ *
63
+ * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
64
+ * the synchronous methods can have significant impact on performance due to
65
+ * stalling the event loop while spawned processes complete.
66
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js)
67
+ */
68
+ declare module 'child_process' {
69
+ import { ObjectEncodingOptions } from 'node:fs';
70
+ import { EventEmitter, Abortable } from 'node:events';
71
+ import * as net from 'node:net';
72
+ import { Writable, Readable, Stream, Pipe } from 'node:stream';
73
+ import { URL } from 'node:url';
74
+ type Serializable = string | object | number | boolean | bigint;
75
+ type SendHandle = net.Socket | net.Server;
76
+ /**
77
+ * Instances of the `ChildProcess` represent spawned child processes.
78
+ *
79
+ * Instances of `ChildProcess` are not intended to be created directly. Rather,
80
+ * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
81
+ * instances of `ChildProcess`.
82
+ * @since v2.2.0
83
+ */
84
+ class ChildProcess extends EventEmitter {
85
+ /**
86
+ * A `Writable Stream` that represents the child process's `stdin`.
87
+ *
88
+ * If a child process waits to read all of its input, the child will not continue
89
+ * until this stream has been closed via `end()`.
90
+ *
91
+ * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
92
+ * then this will be `null`.
93
+ *
94
+ * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
95
+ * refer to the same value.
96
+ *
97
+ * The `subprocess.stdin` property can be `undefined` if the child process could
98
+ * not be successfully spawned.
99
+ * @since v0.1.90
100
+ */
101
+ stdin: Writable | null;
102
+ /**
103
+ * A `Readable Stream` that represents the child process's `stdout`.
104
+ *
105
+ * If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
106
+ * then this will be `null`.
107
+ *
108
+ * `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
109
+ * refer to the same value.
110
+ *
111
+ * ```js
112
+ * const { spawn } = require('child_process');
113
+ *
114
+ * const subprocess = spawn('ls');
115
+ *
116
+ * subprocess.stdout.on('data', (data) => {
117
+ * console.log(`Received chunk ${data}`);
118
+ * });
119
+ * ```
120
+ *
121
+ * The `subprocess.stdout` property can be `null` if the child process could
122
+ * not be successfully spawned.
123
+ * @since v0.1.90
124
+ */
125
+ stdout: Readable | null;
126
+ /**
127
+ * A `Readable Stream` that represents the child process's `stderr`.
128
+ *
129
+ * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
130
+ * then this will be `null`.
131
+ *
132
+ * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
133
+ * refer to the same value.
134
+ *
135
+ * The `subprocess.stderr` property can be `null` if the child process could
136
+ * not be successfully spawned.
137
+ * @since v0.1.90
138
+ */
139
+ stderr: Readable | null;
140
+ /**
141
+ * The `subprocess.channel` property is a reference to the child's IPC channel. If
142
+ * no IPC channel currently exists, this property is `undefined`.
143
+ * @since v7.1.0
144
+ */
145
+ readonly channel?: Pipe | null | undefined;
146
+ /**
147
+ * A sparse array of pipes to the child process, corresponding with positions in
148
+ * the `stdio` option passed to {@link spawn} that have been set
149
+ * to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`,
150
+ * respectively.
151
+ *
152
+ * In the following example, only the child's fd `1` (stdout) is configured as a
153
+ * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
154
+ * in the array are `null`.
155
+ *
156
+ * ```js
157
+ * const assert = require('assert');
158
+ * const fs = require('fs');
159
+ * const child_process = require('child_process');
160
+ *
161
+ * const subprocess = child_process.spawn('ls', {
162
+ * stdio: [
163
+ * 0, // Use parent's stdin for child.
164
+ * 'pipe', // Pipe child's stdout to parent.
165
+ * fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
166
+ * ]
167
+ * });
168
+ *
169
+ * assert.strictEqual(subprocess.stdio[0], null);
170
+ * assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
171
+ *
172
+ * assert(subprocess.stdout);
173
+ * assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
174
+ *
175
+ * assert.strictEqual(subprocess.stdio[2], null);
176
+ * assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
177
+ * ```
178
+ *
179
+ * The `subprocess.stdio` property can be `undefined` if the child process could
180
+ * not be successfully spawned.
181
+ * @since v0.7.10
182
+ */
183
+ readonly stdio: [
184
+ Writable | null,
185
+ // stdin
186
+ Readable | null,
187
+ // stdout
188
+ Readable | null,
189
+ // stderr
190
+ Readable | Writable | null | undefined,
191
+ // extra
192
+ Readable | Writable | null | undefined // extra
193
+ ];
194
+ /**
195
+ * The `subprocess.killed` property indicates whether the child process
196
+ * successfully received a signal from `subprocess.kill()`. The `killed` property
197
+ * does not indicate that the child process has been terminated.
198
+ * @since v0.5.10
199
+ */
200
+ readonly killed: boolean;
201
+ /**
202
+ * Returns the process identifier (PID) of the child process. If the child process
203
+ * fails to spawn due to errors, then the value is `undefined` and `error` is
204
+ * emitted.
205
+ *
206
+ * ```js
207
+ * const { spawn } = require('child_process');
208
+ * const grep = spawn('grep', ['ssh']);
209
+ *
210
+ * console.log(`Spawned child pid: ${grep.pid}`);
211
+ * grep.stdin.end();
212
+ * ```
213
+ * @since v0.1.90
214
+ */
215
+ readonly pid?: number | undefined;
216
+ /**
217
+ * The `subprocess.connected` property indicates whether it is still possible to
218
+ * send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages.
219
+ * @since v0.7.2
220
+ */
221
+ readonly connected: boolean;
222
+ /**
223
+ * The `subprocess.exitCode` property indicates the exit code of the child process.
224
+ * If the child process is still running, the field will be `null`.
225
+ */
226
+ readonly exitCode: number | null;
227
+ /**
228
+ * The `subprocess.signalCode` property indicates the signal received by
229
+ * the child process if any, else `null`.
230
+ */
231
+ readonly signalCode: NodeJS.Signals | null;
232
+ /**
233
+ * The `subprocess.spawnargs` property represents the full list of command-line
234
+ * arguments the child process was launched with.
235
+ */
236
+ readonly spawnargs: string[];
237
+ /**
238
+ * The `subprocess.spawnfile` property indicates the executable file name of
239
+ * the child process that is launched.
240
+ *
241
+ * For {@link fork}, its value will be equal to `process.execPath`.
242
+ * For {@link spawn}, its value will be the name of
243
+ * the executable file.
244
+ * For {@link exec}, its value will be the name of the shell
245
+ * in which the child process is launched.
246
+ */
247
+ readonly spawnfile: string;
248
+ /**
249
+ * The `subprocess.kill()` method sends a signal to the child process. If no
250
+ * argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
251
+ * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
252
+ *
253
+ * ```js
254
+ * const { spawn } = require('child_process');
255
+ * const grep = spawn('grep', ['ssh']);
256
+ *
257
+ * grep.on('close', (code, signal) => {
258
+ * console.log(
259
+ * `child process terminated due to receipt of signal ${signal}`);
260
+ * });
261
+ *
262
+ * // Send SIGHUP to process.
263
+ * grep.kill('SIGHUP');
264
+ * ```
265
+ *
266
+ * The `ChildProcess` object may emit an `'error'` event if the signal
267
+ * cannot be delivered. Sending a signal to a child process that has already exited
268
+ * is not an error but may have unforeseen consequences. Specifically, if the
269
+ * process identifier (PID) has been reassigned to another process, the signal will
270
+ * be delivered to that process instead which can have unexpected results.
271
+ *
272
+ * While the function is called `kill`, the signal delivered to the child process
273
+ * may not actually terminate the process.
274
+ *
275
+ * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
276
+ *
277
+ * On Windows, where POSIX signals do not exist, the `signal` argument will be
278
+ * ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`).
279
+ * See `Signal Events` for more details.
280
+ *
281
+ * On Linux, child processes of child processes will not be terminated
282
+ * when attempting to kill their parent. This is likely to happen when running a
283
+ * new process in a shell or with the use of the `shell` option of `ChildProcess`:
284
+ *
285
+ * ```js
286
+ * 'use strict';
287
+ * const { spawn } = require('child_process');
288
+ *
289
+ * const subprocess = spawn(
290
+ * 'sh',
291
+ * [
292
+ * '-c',
293
+ * `node -e "setInterval(() => {
294
+ * console.log(process.pid, 'is alive')
295
+ * }, 500);"`,
296
+ * ], {
297
+ * stdio: ['inherit', 'inherit', 'inherit']
298
+ * }
299
+ * );
300
+ *
301
+ * setTimeout(() => {
302
+ * subprocess.kill(); // Does not terminate the Node.js process in the shell.
303
+ * }, 2000);
304
+ * ```
305
+ * @since v0.1.90
306
+ */
307
+ kill(signal?: NodeJS.Signals | number): boolean;
308
+ /**
309
+ * When an IPC channel has been established between the parent and child (
310
+ * i.e. when using {@link fork}), the `subprocess.send()` method can
311
+ * be used to send messages to the child process. When the child process is a
312
+ * Node.js instance, these messages can be received via the `'message'` event.
313
+ *
314
+ * The message goes through serialization and parsing. The resulting
315
+ * message might not be the same as what is originally sent.
316
+ *
317
+ * For example, in the parent script:
318
+ *
319
+ * ```js
320
+ * const cp = require('child_process');
321
+ * const n = cp.fork(`${__dirname}/sub.js`);
322
+ *
323
+ * n.on('message', (m) => {
324
+ * console.log('PARENT got message:', m);
325
+ * });
326
+ *
327
+ * // Causes the child to print: CHILD got message: { hello: 'world' }
328
+ * n.send({ hello: 'world' });
329
+ * ```
330
+ *
331
+ * And then the child script, `'sub.js'` might look like this:
332
+ *
333
+ * ```js
334
+ * process.on('message', (m) => {
335
+ * console.log('CHILD got message:', m);
336
+ * });
337
+ *
338
+ * // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }
339
+ * process.send({ foo: 'bar', baz: NaN });
340
+ * ```
341
+ *
342
+ * Child Node.js processes will have a `process.send()` method of their own
343
+ * that allows the child to send messages back to the parent.
344
+ *
345
+ * There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
346
+ * containing a `NODE_` prefix in the `cmd` property are reserved for use within
347
+ * Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js.
348
+ * Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice.
349
+ *
350
+ * The optional `sendHandle` argument that may be passed to `subprocess.send()` is
351
+ * for passing a TCP server or socket object to the child process. The child will
352
+ * receive the object as the second argument passed to the callback function
353
+ * registered on the `'message'` event. Any data that is received
354
+ * and buffered in the socket will not be sent to the child.
355
+ *
356
+ * The optional `callback` is a function that is invoked after the message is
357
+ * sent but before the child may have received it. The function is called with a
358
+ * single argument: `null` on success, or an `Error` object on failure.
359
+ *
360
+ * If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can
361
+ * happen, for instance, when the child process has already exited.
362
+ *
363
+ * `subprocess.send()` will return `false` if the channel has closed or when the
364
+ * backlog of unsent messages exceeds a threshold that makes it unwise to send
365
+ * more. Otherwise, the method returns `true`. The `callback` function can be
366
+ * used to implement flow control.
367
+ *
368
+ * #### Example: sending a server object
369
+ *
370
+ * The `sendHandle` argument can be used, for instance, to pass the handle of
371
+ * a TCP server object to the child process as illustrated in the example below:
372
+ *
373
+ * ```js
374
+ * const subprocess = require('child_process').fork('subprocess.js');
375
+ *
376
+ * // Open up the server object and send the handle.
377
+ * const server = require('net').createServer();
378
+ * server.on('connection', (socket) => {
379
+ * socket.end('handled by parent');
380
+ * });
381
+ * server.listen(1337, () => {
382
+ * subprocess.send('server', server);
383
+ * });
384
+ * ```
385
+ *
386
+ * The child would then receive the server object as:
387
+ *
388
+ * ```js
389
+ * process.on('message', (m, server) => {
390
+ * if (m === 'server') {
391
+ * server.on('connection', (socket) => {
392
+ * socket.end('handled by child');
393
+ * });
394
+ * }
395
+ * });
396
+ * ```
397
+ *
398
+ * Once the server is now shared between the parent and child, some connections
399
+ * can be handled by the parent and some by the child.
400
+ *
401
+ * While the example above uses a server created using the `net` module, `dgram`module servers use exactly the same workflow with the exceptions of listening on
402
+ * a `'message'` event instead of `'connection'` and using `server.bind()` instead
403
+ * of `server.listen()`. This is, however, currently only supported on Unix
404
+ * platforms.
405
+ *
406
+ * #### Example: sending a socket object
407
+ *
408
+ * Similarly, the `sendHandler` argument can be used to pass the handle of a
409
+ * socket to the child process. The example below spawns two children that each
410
+ * handle connections with "normal" or "special" priority:
411
+ *
412
+ * ```js
413
+ * const { fork } = require('child_process');
414
+ * const normal = fork('subprocess.js', ['normal']);
415
+ * const special = fork('subprocess.js', ['special']);
416
+ *
417
+ * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
418
+ * // the sockets from being read before they are sent to the child process.
419
+ * const server = require('net').createServer({ pauseOnConnect: true });
420
+ * server.on('connection', (socket) => {
421
+ *
422
+ * // If this is special priority...
423
+ * if (socket.remoteAddress === '74.125.127.100') {
424
+ * special.send('socket', socket);
425
+ * return;
426
+ * }
427
+ * // This is normal priority.
428
+ * normal.send('socket', socket);
429
+ * });
430
+ * server.listen(1337);
431
+ * ```
432
+ *
433
+ * The `subprocess.js` would receive the socket handle as the second argument
434
+ * passed to the event callback function:
435
+ *
436
+ * ```js
437
+ * process.on('message', (m, socket) => {
438
+ * if (m === 'socket') {
439
+ * if (socket) {
440
+ * // Check that the client socket exists.
441
+ * // It is possible for the socket to be closed between the time it is
442
+ * // sent and the time it is received in the child process.
443
+ * socket.end(`Request handled with ${process.argv[2]} priority`);
444
+ * }
445
+ * }
446
+ * });
447
+ * ```
448
+ *
449
+ * Do not use `.maxConnections` on a socket that has been passed to a subprocess.
450
+ * The parent cannot track when the socket is destroyed.
451
+ *
452
+ * Any `'message'` handlers in the subprocess should verify that `socket` exists,
453
+ * as the connection may have been closed during the time it takes to send the
454
+ * connection to the child.
455
+ * @since v0.5.9
456
+ * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
457
+ */
458
+ send(message: Serializable, callback?: (error: Error | null) => void): boolean;
459
+ send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
460
+ send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
461
+ /**
462
+ * Closes the IPC channel between parent and child, allowing the child to exit
463
+ * gracefully once there are no other connections keeping it alive. After calling
464
+ * this method the `subprocess.connected` and `process.connected` properties in
465
+ * both the parent and child (respectively) will be set to `false`, and it will be
466
+ * no longer possible to pass messages between the processes.
467
+ *
468
+ * The `'disconnect'` event will be emitted when there are no messages in the
469
+ * process of being received. This will most often be triggered immediately after
470
+ * calling `subprocess.disconnect()`.
471
+ *
472
+ * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
473
+ * within the child process to close the IPC channel as well.
474
+ * @since v0.7.2
475
+ */
476
+ disconnect(): void;
477
+ /**
478
+ * By default, the parent will wait for the detached child to exit. To prevent the
479
+ * parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not
480
+ * include the child in its reference count, allowing the parent to exit
481
+ * independently of the child, unless there is an established IPC channel between
482
+ * the child and the parent.
483
+ *
484
+ * ```js
485
+ * const { spawn } = require('child_process');
486
+ *
487
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
488
+ * detached: true,
489
+ * stdio: 'ignore'
490
+ * });
491
+ *
492
+ * subprocess.unref();
493
+ * ```
494
+ * @since v0.7.10
495
+ */
496
+ unref(): void;
497
+ /**
498
+ * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
499
+ * restore the removed reference count for the child process, forcing the parent
500
+ * to wait for the child to exit before exiting itself.
501
+ *
502
+ * ```js
503
+ * const { spawn } = require('child_process');
504
+ *
505
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
506
+ * detached: true,
507
+ * stdio: 'ignore'
508
+ * });
509
+ *
510
+ * subprocess.unref();
511
+ * subprocess.ref();
512
+ * ```
513
+ * @since v0.7.10
514
+ */
515
+ ref(): void;
516
+ /**
517
+ * events.EventEmitter
518
+ * 1. close
519
+ * 2. disconnect
520
+ * 3. error
521
+ * 4. exit
522
+ * 5. message
523
+ * 6. spawn
524
+ */
525
+ addListener(event: string, listener: (...args: any[]) => void): this;
526
+ addListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
527
+ addListener(event: 'disconnect', listener: () => void): this;
528
+ addListener(event: 'error', listener: (err: Error) => void): this;
529
+ addListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
530
+ addListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
531
+ addListener(event: 'spawn', listener: () => void): this;
532
+ emit(event: string | symbol, ...args: any[]): boolean;
533
+ emit(event: 'close', code: number | null, signal: NodeJS.Signals | null): boolean;
534
+ emit(event: 'disconnect'): boolean;
535
+ emit(event: 'error', err: Error): boolean;
536
+ emit(event: 'exit', code: number | null, signal: NodeJS.Signals | null): boolean;
537
+ emit(event: 'message', message: Serializable, sendHandle: SendHandle): boolean;
538
+ emit(event: 'spawn', listener: () => void): boolean;
539
+ on(event: string, listener: (...args: any[]) => void): this;
540
+ on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
541
+ on(event: 'disconnect', listener: () => void): this;
542
+ on(event: 'error', listener: (err: Error) => void): this;
543
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
544
+ on(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
545
+ on(event: 'spawn', listener: () => void): this;
546
+ once(event: string, listener: (...args: any[]) => void): this;
547
+ once(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
548
+ once(event: 'disconnect', listener: () => void): this;
549
+ once(event: 'error', listener: (err: Error) => void): this;
550
+ once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
551
+ once(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
552
+ once(event: 'spawn', listener: () => void): this;
553
+ prependListener(event: string, listener: (...args: any[]) => void): this;
554
+ prependListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
555
+ prependListener(event: 'disconnect', listener: () => void): this;
556
+ prependListener(event: 'error', listener: (err: Error) => void): this;
557
+ prependListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
558
+ prependListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
559
+ prependListener(event: 'spawn', listener: () => void): this;
560
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
561
+ prependOnceListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
562
+ prependOnceListener(event: 'disconnect', listener: () => void): this;
563
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
564
+ prependOnceListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
565
+ prependOnceListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
566
+ prependOnceListener(event: 'spawn', listener: () => void): this;
567
+ }
568
+ // return this object when stdio option is undefined or not specified
569
+ interface ChildProcessWithoutNullStreams extends ChildProcess {
570
+ stdin: Writable;
571
+ stdout: Readable;
572
+ stderr: Readable;
573
+ readonly stdio: [
574
+ Writable,
575
+ Readable,
576
+ Readable,
577
+ // stderr
578
+ Readable | Writable | null | undefined,
579
+ // extra, no modification
580
+ Readable | Writable | null | undefined // extra, no modification
581
+ ];
582
+ }
583
+ // return this object when stdio option is a tuple of 3
584
+ interface ChildProcessByStdio<I extends null | Writable, O extends null | Readable, E extends null | Readable> extends ChildProcess {
585
+ stdin: I;
586
+ stdout: O;
587
+ stderr: E;
588
+ readonly stdio: [
589
+ I,
590
+ O,
591
+ E,
592
+ Readable | Writable | null | undefined,
593
+ // extra, no modification
594
+ Readable | Writable | null | undefined // extra, no modification
595
+ ];
596
+ }
597
+ interface MessageOptions {
598
+ keepOpen?: boolean | undefined;
599
+ }
600
+ type IOType = 'overlapped' | 'pipe' | 'ignore' | 'inherit';
601
+ type StdioOptions = IOType | Array<IOType | 'ipc' | Stream | number | null | undefined>;
602
+ type SerializationType = 'json' | 'advanced';
603
+ interface MessagingOptions extends Abortable {
604
+ /**
605
+ * Specify the kind of serialization used for sending messages between processes.
606
+ * @default 'json'
607
+ */
608
+ serialization?: SerializationType | undefined;
609
+ /**
610
+ * The signal value to be used when the spawned process will be killed by the abort signal.
611
+ * @default 'SIGTERM'
612
+ */
613
+ killSignal?: NodeJS.Signals | number | undefined;
614
+ /**
615
+ * In milliseconds the maximum amount of time the process is allowed to run.
616
+ */
617
+ timeout?: number | undefined;
618
+ }
619
+ interface ProcessEnvOptions {
620
+ uid?: number | undefined;
621
+ gid?: number | undefined;
622
+ cwd?: string | URL | undefined;
623
+ env?: NodeJS.ProcessEnv | undefined;
624
+ }
625
+ interface CommonOptions extends ProcessEnvOptions {
626
+ /**
627
+ * @default false
628
+ */
629
+ windowsHide?: boolean | undefined;
630
+ /**
631
+ * @default 0
632
+ */
633
+ timeout?: number | undefined;
634
+ }
635
+ interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
636
+ argv0?: string | undefined;
637
+ stdio?: StdioOptions | undefined;
638
+ shell?: boolean | string | undefined;
639
+ windowsVerbatimArguments?: boolean | undefined;
640
+ }
641
+ interface SpawnOptions extends CommonSpawnOptions {
642
+ detached?: boolean | undefined;
643
+ }
644
+ interface SpawnOptionsWithoutStdio extends SpawnOptions {
645
+ stdio?: StdioPipeNamed | StdioPipe[] | undefined;
646
+ }
647
+ type StdioNull = 'inherit' | 'ignore' | Stream;
648
+ type StdioPipeNamed = 'pipe' | 'overlapped';
649
+ type StdioPipe = undefined | null | StdioPipeNamed;
650
+ interface SpawnOptionsWithStdioTuple<Stdin extends StdioNull | StdioPipe, Stdout extends StdioNull | StdioPipe, Stderr extends StdioNull | StdioPipe> extends SpawnOptions {
651
+ stdio: [Stdin, Stdout, Stderr];
652
+ }
653
+ /**
654
+ * The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults
655
+ * to an empty array.
656
+ *
657
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
658
+ * **function. Any input containing shell metacharacters may be used to trigger**
659
+ * **arbitrary command execution.**
660
+ *
661
+ * A third argument may be used to specify additional options, with these defaults:
662
+ *
663
+ * ```js
664
+ * const defaults = {
665
+ * cwd: undefined,
666
+ * env: process.env
667
+ * };
668
+ * ```
669
+ *
670
+ * Use `cwd` to specify the working directory from which the process is spawned.
671
+ * If not given, the default is to inherit the current working directory. If given,
672
+ * but the path does not exist, the child process emits an `ENOENT` error
673
+ * and exits immediately. `ENOENT` is also emitted when the command
674
+ * does not exist.
675
+ *
676
+ * Use `env` to specify environment variables that will be visible to the new
677
+ * process, the default is `process.env`.
678
+ *
679
+ * `undefined` values in `env` will be ignored.
680
+ *
681
+ * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
682
+ * exit code:
683
+ *
684
+ * ```js
685
+ * const { spawn } = require('child_process');
686
+ * const ls = spawn('ls', ['-lh', '/usr']);
687
+ *
688
+ * ls.stdout.on('data', (data) => {
689
+ * console.log(`stdout: ${data}`);
690
+ * });
691
+ *
692
+ * ls.stderr.on('data', (data) => {
693
+ * console.error(`stderr: ${data}`);
694
+ * });
695
+ *
696
+ * ls.on('close', (code) => {
697
+ * console.log(`child process exited with code ${code}`);
698
+ * });
699
+ * ```
700
+ *
701
+ * Example: A very elaborate way to run `ps ax | grep ssh`
702
+ *
703
+ * ```js
704
+ * const { spawn } = require('child_process');
705
+ * const ps = spawn('ps', ['ax']);
706
+ * const grep = spawn('grep', ['ssh']);
707
+ *
708
+ * ps.stdout.on('data', (data) => {
709
+ * grep.stdin.write(data);
710
+ * });
711
+ *
712
+ * ps.stderr.on('data', (data) => {
713
+ * console.error(`ps stderr: ${data}`);
714
+ * });
715
+ *
716
+ * ps.on('close', (code) => {
717
+ * if (code !== 0) {
718
+ * console.log(`ps process exited with code ${code}`);
719
+ * }
720
+ * grep.stdin.end();
721
+ * });
722
+ *
723
+ * grep.stdout.on('data', (data) => {
724
+ * console.log(data.toString());
725
+ * });
726
+ *
727
+ * grep.stderr.on('data', (data) => {
728
+ * console.error(`grep stderr: ${data}`);
729
+ * });
730
+ *
731
+ * grep.on('close', (code) => {
732
+ * if (code !== 0) {
733
+ * console.log(`grep process exited with code ${code}`);
734
+ * }
735
+ * });
736
+ * ```
737
+ *
738
+ * Example of checking for failed `spawn`:
739
+ *
740
+ * ```js
741
+ * const { spawn } = require('child_process');
742
+ * const subprocess = spawn('bad_command');
743
+ *
744
+ * subprocess.on('error', (err) => {
745
+ * console.error('Failed to start subprocess.');
746
+ * });
747
+ * ```
748
+ *
749
+ * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
750
+ * title while others (Windows, SunOS) will use `command`.
751
+ *
752
+ * Node.js currently overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent,
753
+ * retrieve it with the`process.argv0` property instead.
754
+ *
755
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
756
+ * the error passed to the callback will be an `AbortError`:
757
+ *
758
+ * ```js
759
+ * const { spawn } = require('child_process');
760
+ * const controller = new AbortController();
761
+ * const { signal } = controller;
762
+ * const grep = spawn('grep', ['ssh'], { signal });
763
+ * grep.on('error', (err) => {
764
+ * // This will be called with err being an AbortError if the controller aborts
765
+ * });
766
+ * controller.abort(); // Stops the child process
767
+ * ```
768
+ * @since v0.1.90
769
+ * @param command The command to run.
770
+ * @param args List of string arguments.
771
+ */
772
+ function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
773
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
774
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
775
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
776
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
777
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
778
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
779
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
780
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
781
+ function spawn(command: string, options: SpawnOptions): ChildProcess;
782
+ // overloads of spawn with 'args'
783
+ function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
784
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
785
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
786
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
787
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
788
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
789
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
790
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
791
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
792
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
793
+ interface ExecOptions extends CommonOptions {
794
+ shell?: string | undefined;
795
+ signal?: AbortSignal | undefined;
796
+ maxBuffer?: number | undefined;
797
+ killSignal?: NodeJS.Signals | number | undefined;
798
+ }
799
+ interface ExecOptionsWithStringEncoding extends ExecOptions {
800
+ encoding: BufferEncoding;
801
+ }
802
+ interface ExecOptionsWithBufferEncoding extends ExecOptions {
803
+ encoding: BufferEncoding | null; // specify `null`.
804
+ }
805
+ interface ExecException extends Error {
806
+ cmd?: string | undefined;
807
+ killed?: boolean | undefined;
808
+ code?: number | undefined;
809
+ signal?: NodeJS.Signals | undefined;
810
+ }
811
+ /**
812
+ * Spawns a shell then executes the `command` within that shell, buffering any
813
+ * generated output. The `command` string passed to the exec function is processed
814
+ * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
815
+ * need to be dealt with accordingly:
816
+ *
817
+ * ```js
818
+ * const { exec } = require('child_process');
819
+ *
820
+ * exec('"/path/to/test file/test.sh" arg1 arg2');
821
+ * // Double quotes are used so that the space in the path is not interpreted as
822
+ * // a delimiter of multiple arguments.
823
+ *
824
+ * exec('echo "The \\$HOME variable is $HOME"');
825
+ * // The $HOME variable is escaped in the first instance, but not in the second.
826
+ * ```
827
+ *
828
+ * **Never pass unsanitized user input to this function. Any input containing shell**
829
+ * **metacharacters may be used to trigger arbitrary command execution.**
830
+ *
831
+ * If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The
832
+ * `error.code` property will be
833
+ * the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the
834
+ * process.
835
+ *
836
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
837
+ * stdout and stderr output of the child process. By default, Node.js will decode
838
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
839
+ * can be used to specify the character encoding used to decode the stdout and
840
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
841
+ * encoding, `Buffer` objects will be passed to the callback instead.
842
+ *
843
+ * ```js
844
+ * const { exec } = require('child_process');
845
+ * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
846
+ * if (error) {
847
+ * console.error(`exec error: ${error}`);
848
+ * return;
849
+ * }
850
+ * console.log(`stdout: ${stdout}`);
851
+ * console.error(`stderr: ${stderr}`);
852
+ * });
853
+ * ```
854
+ *
855
+ * If `timeout` is greater than `0`, the parent will send the signal
856
+ * identified by the `killSignal` property (the default is `'SIGTERM'`) if the
857
+ * child runs longer than `timeout` milliseconds.
858
+ *
859
+ * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
860
+ * the existing process and uses a shell to execute the command.
861
+ *
862
+ * If this method is invoked as its `util.promisify()` ed version, it returns
863
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
864
+ * case of an error (including any error resulting in an exit code other than 0), a
865
+ * rejected promise is returned, with the same `error` object given in the
866
+ * callback, but with two additional properties `stdout` and `stderr`.
867
+ *
868
+ * ```js
869
+ * const util = require('util');
870
+ * const exec = util.promisify(require('child_process').exec);
871
+ *
872
+ * async function lsExample() {
873
+ * const { stdout, stderr } = await exec('ls');
874
+ * console.log('stdout:', stdout);
875
+ * console.error('stderr:', stderr);
876
+ * }
877
+ * lsExample();
878
+ * ```
879
+ *
880
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
881
+ * the error passed to the callback will be an `AbortError`:
882
+ *
883
+ * ```js
884
+ * const { exec } = require('child_process');
885
+ * const controller = new AbortController();
886
+ * const { signal } = controller;
887
+ * const child = exec('grep ssh', { signal }, (error) => {
888
+ * console.log(error); // an AbortError
889
+ * });
890
+ * controller.abort();
891
+ * ```
892
+ * @since v0.1.90
893
+ * @param command The command to run, with space-separated arguments.
894
+ * @param callback called with the output when process terminates.
895
+ */
896
+ function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
897
+ // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
898
+ function exec(
899
+ command: string,
900
+ options: {
901
+ encoding: 'buffer' | null;
902
+ } & ExecOptions,
903
+ callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void
904
+ ): ChildProcess;
905
+ // `options` with well known `encoding` means stdout/stderr are definitely `string`.
906
+ function exec(
907
+ command: string,
908
+ options: {
909
+ encoding: BufferEncoding;
910
+ } & ExecOptions,
911
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void
912
+ ): ChildProcess;
913
+ // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
914
+ // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
915
+ function exec(
916
+ command: string,
917
+ options: {
918
+ encoding: BufferEncoding;
919
+ } & ExecOptions,
920
+ callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
921
+ ): ChildProcess;
922
+ // `options` without an `encoding` means stdout/stderr are definitely `string`.
923
+ function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
924
+ // fallback if nothing else matches. Worst case is always `string | Buffer`.
925
+ function exec(
926
+ command: string,
927
+ options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
928
+ callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
929
+ ): ChildProcess;
930
+ interface PromiseWithChild<T> extends Promise<T> {
931
+ child: ChildProcess;
932
+ }
933
+ namespace exec {
934
+ function __promisify__(command: string): PromiseWithChild<{
935
+ stdout: string;
936
+ stderr: string;
937
+ }>;
938
+ function __promisify__(
939
+ command: string,
940
+ options: {
941
+ encoding: 'buffer' | null;
942
+ } & ExecOptions
943
+ ): PromiseWithChild<{
944
+ stdout: Buffer;
945
+ stderr: Buffer;
946
+ }>;
947
+ function __promisify__(
948
+ command: string,
949
+ options: {
950
+ encoding: BufferEncoding;
951
+ } & ExecOptions
952
+ ): PromiseWithChild<{
953
+ stdout: string;
954
+ stderr: string;
955
+ }>;
956
+ function __promisify__(
957
+ command: string,
958
+ options: ExecOptions
959
+ ): PromiseWithChild<{
960
+ stdout: string;
961
+ stderr: string;
962
+ }>;
963
+ function __promisify__(
964
+ command: string,
965
+ options?: (ObjectEncodingOptions & ExecOptions) | null
966
+ ): PromiseWithChild<{
967
+ stdout: string | Buffer;
968
+ stderr: string | Buffer;
969
+ }>;
970
+ }
971
+ interface ExecFileOptions extends CommonOptions, Abortable {
972
+ maxBuffer?: number | undefined;
973
+ killSignal?: NodeJS.Signals | number | undefined;
974
+ windowsVerbatimArguments?: boolean | undefined;
975
+ shell?: boolean | string | undefined;
976
+ signal?: AbortSignal | undefined;
977
+ }
978
+ interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
979
+ encoding: BufferEncoding;
980
+ }
981
+ interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
982
+ encoding: 'buffer' | null;
983
+ }
984
+ interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
985
+ encoding: BufferEncoding;
986
+ }
987
+ type ExecFileException = ExecException & NodeJS.ErrnoException;
988
+ /**
989
+ * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
990
+ * executable `file` is spawned directly as a new process making it slightly more
991
+ * efficient than {@link exec}.
992
+ *
993
+ * The same options as {@link exec} are supported. Since a shell is
994
+ * not spawned, behaviors such as I/O redirection and file globbing are not
995
+ * supported.
996
+ *
997
+ * ```js
998
+ * const { execFile } = require('child_process');
999
+ * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
1000
+ * if (error) {
1001
+ * throw error;
1002
+ * }
1003
+ * console.log(stdout);
1004
+ * });
1005
+ * ```
1006
+ *
1007
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
1008
+ * stdout and stderr output of the child process. By default, Node.js will decode
1009
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
1010
+ * can be used to specify the character encoding used to decode the stdout and
1011
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
1012
+ * encoding, `Buffer` objects will be passed to the callback instead.
1013
+ *
1014
+ * If this method is invoked as its `util.promisify()` ed version, it returns
1015
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
1016
+ * case of an error (including any error resulting in an exit code other than 0), a
1017
+ * rejected promise is returned, with the same `error` object given in the
1018
+ * callback, but with two additional properties `stdout` and `stderr`.
1019
+ *
1020
+ * ```js
1021
+ * const util = require('util');
1022
+ * const execFile = util.promisify(require('child_process').execFile);
1023
+ * async function getVersion() {
1024
+ * const { stdout } = await execFile('node', ['--version']);
1025
+ * console.log(stdout);
1026
+ * }
1027
+ * getVersion();
1028
+ * ```
1029
+ *
1030
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1031
+ * **function. Any input containing shell metacharacters may be used to trigger**
1032
+ * **arbitrary command execution.**
1033
+ *
1034
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
1035
+ * the error passed to the callback will be an `AbortError`:
1036
+ *
1037
+ * ```js
1038
+ * const { execFile } = require('child_process');
1039
+ * const controller = new AbortController();
1040
+ * const { signal } = controller;
1041
+ * const child = execFile('node', ['--version'], { signal }, (error) => {
1042
+ * console.log(error); // an AbortError
1043
+ * });
1044
+ * controller.abort();
1045
+ * ```
1046
+ * @since v0.1.91
1047
+ * @param file The name or path of the executable file to run.
1048
+ * @param args List of string arguments.
1049
+ * @param callback Called with the output when process terminates.
1050
+ */
1051
+ function execFile(file: string): ChildProcess;
1052
+ function execFile(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
1053
+ function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
1054
+ function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
1055
+ // no `options` definitely means stdout/stderr are `string`.
1056
+ function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
1057
+ function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
1058
+ // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
1059
+ function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
1060
+ function execFile(
1061
+ file: string,
1062
+ args: ReadonlyArray<string> | undefined | null,
1063
+ options: ExecFileOptionsWithBufferEncoding,
1064
+ callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void
1065
+ ): ChildProcess;
1066
+ // `options` with well known `encoding` means stdout/stderr are definitely `string`.
1067
+ function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
1068
+ function execFile(
1069
+ file: string,
1070
+ args: ReadonlyArray<string> | undefined | null,
1071
+ options: ExecFileOptionsWithStringEncoding,
1072
+ callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
1073
+ ): ChildProcess;
1074
+ // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
1075
+ // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
1076
+ function execFile(file: string, options: ExecFileOptionsWithOtherEncoding, callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
1077
+ function execFile(
1078
+ file: string,
1079
+ args: ReadonlyArray<string> | undefined | null,
1080
+ options: ExecFileOptionsWithOtherEncoding,
1081
+ callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void
1082
+ ): ChildProcess;
1083
+ // `options` without an `encoding` means stdout/stderr are definitely `string`.
1084
+ function execFile(file: string, options: ExecFileOptions, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
1085
+ function execFile(
1086
+ file: string,
1087
+ args: ReadonlyArray<string> | undefined | null,
1088
+ options: ExecFileOptions,
1089
+ callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
1090
+ ): ChildProcess;
1091
+ // fallback if nothing else matches. Worst case is always `string | Buffer`.
1092
+ function execFile(
1093
+ file: string,
1094
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1095
+ callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
1096
+ ): ChildProcess;
1097
+ function execFile(
1098
+ file: string,
1099
+ args: ReadonlyArray<string> | undefined | null,
1100
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1101
+ callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
1102
+ ): ChildProcess;
1103
+ namespace execFile {
1104
+ function __promisify__(file: string): PromiseWithChild<{
1105
+ stdout: string;
1106
+ stderr: string;
1107
+ }>;
1108
+ function __promisify__(
1109
+ file: string,
1110
+ args: ReadonlyArray<string> | undefined | null
1111
+ ): PromiseWithChild<{
1112
+ stdout: string;
1113
+ stderr: string;
1114
+ }>;
1115
+ function __promisify__(
1116
+ file: string,
1117
+ options: ExecFileOptionsWithBufferEncoding
1118
+ ): PromiseWithChild<{
1119
+ stdout: Buffer;
1120
+ stderr: Buffer;
1121
+ }>;
1122
+ function __promisify__(
1123
+ file: string,
1124
+ args: ReadonlyArray<string> | undefined | null,
1125
+ options: ExecFileOptionsWithBufferEncoding
1126
+ ): PromiseWithChild<{
1127
+ stdout: Buffer;
1128
+ stderr: Buffer;
1129
+ }>;
1130
+ function __promisify__(
1131
+ file: string,
1132
+ options: ExecFileOptionsWithStringEncoding
1133
+ ): PromiseWithChild<{
1134
+ stdout: string;
1135
+ stderr: string;
1136
+ }>;
1137
+ function __promisify__(
1138
+ file: string,
1139
+ args: ReadonlyArray<string> | undefined | null,
1140
+ options: ExecFileOptionsWithStringEncoding
1141
+ ): PromiseWithChild<{
1142
+ stdout: string;
1143
+ stderr: string;
1144
+ }>;
1145
+ function __promisify__(
1146
+ file: string,
1147
+ options: ExecFileOptionsWithOtherEncoding
1148
+ ): PromiseWithChild<{
1149
+ stdout: string | Buffer;
1150
+ stderr: string | Buffer;
1151
+ }>;
1152
+ function __promisify__(
1153
+ file: string,
1154
+ args: ReadonlyArray<string> | undefined | null,
1155
+ options: ExecFileOptionsWithOtherEncoding
1156
+ ): PromiseWithChild<{
1157
+ stdout: string | Buffer;
1158
+ stderr: string | Buffer;
1159
+ }>;
1160
+ function __promisify__(
1161
+ file: string,
1162
+ options: ExecFileOptions
1163
+ ): PromiseWithChild<{
1164
+ stdout: string;
1165
+ stderr: string;
1166
+ }>;
1167
+ function __promisify__(
1168
+ file: string,
1169
+ args: ReadonlyArray<string> | undefined | null,
1170
+ options: ExecFileOptions
1171
+ ): PromiseWithChild<{
1172
+ stdout: string;
1173
+ stderr: string;
1174
+ }>;
1175
+ function __promisify__(
1176
+ file: string,
1177
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
1178
+ ): PromiseWithChild<{
1179
+ stdout: string | Buffer;
1180
+ stderr: string | Buffer;
1181
+ }>;
1182
+ function __promisify__(
1183
+ file: string,
1184
+ args: ReadonlyArray<string> | undefined | null,
1185
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
1186
+ ): PromiseWithChild<{
1187
+ stdout: string | Buffer;
1188
+ stderr: string | Buffer;
1189
+ }>;
1190
+ }
1191
+ interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
1192
+ execPath?: string | undefined;
1193
+ execArgv?: string[] | undefined;
1194
+ silent?: boolean | undefined;
1195
+ stdio?: StdioOptions | undefined;
1196
+ detached?: boolean | undefined;
1197
+ windowsVerbatimArguments?: boolean | undefined;
1198
+ }
1199
+ /**
1200
+ * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
1201
+ * Like {@link spawn}, a `ChildProcess` object is returned. The
1202
+ * returned `ChildProcess` will have an additional communication channel
1203
+ * built-in that allows messages to be passed back and forth between the parent and
1204
+ * child. See `subprocess.send()` for details.
1205
+ *
1206
+ * Keep in mind that spawned Node.js child processes are
1207
+ * independent of the parent with exception of the IPC communication channel
1208
+ * that is established between the two. Each process has its own memory, with
1209
+ * their own V8 instances. Because of the additional resource allocations
1210
+ * required, spawning a large number of child Node.js processes is not
1211
+ * recommended.
1212
+ *
1213
+ * By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative
1214
+ * execution path to be used.
1215
+ *
1216
+ * Node.js processes launched with a custom `execPath` will communicate with the
1217
+ * parent process using the file descriptor (fd) identified using the
1218
+ * environment variable `NODE_CHANNEL_FD` on the child process.
1219
+ *
1220
+ * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
1221
+ * current process.
1222
+ *
1223
+ * The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
1224
+ *
1225
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
1226
+ * the error passed to the callback will be an `AbortError`:
1227
+ *
1228
+ * ```js
1229
+ * if (process.argv[2] === 'child') {
1230
+ * setTimeout(() => {
1231
+ * console.log(`Hello from ${process.argv[2]}!`);
1232
+ * }, 1_000);
1233
+ * } else {
1234
+ * const { fork } = require('child_process');
1235
+ * const controller = new AbortController();
1236
+ * const { signal } = controller;
1237
+ * const child = fork(__filename, ['child'], { signal });
1238
+ * child.on('error', (err) => {
1239
+ * // This will be called with err being an AbortError if the controller aborts
1240
+ * });
1241
+ * controller.abort(); // Stops the child process
1242
+ * }
1243
+ * ```
1244
+ * @since v0.5.0
1245
+ * @param modulePath The module to run in the child.
1246
+ * @param args List of string arguments.
1247
+ */
1248
+ function fork(modulePath: string, options?: ForkOptions): ChildProcess;
1249
+ function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
1250
+ interface SpawnSyncOptions extends CommonSpawnOptions {
1251
+ input?: string | NodeJS.ArrayBufferView | undefined;
1252
+ maxBuffer?: number | undefined;
1253
+ encoding?: BufferEncoding | 'buffer' | null | undefined;
1254
+ }
1255
+ interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1256
+ encoding: BufferEncoding;
1257
+ }
1258
+ interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1259
+ encoding?: 'buffer' | null | undefined;
1260
+ }
1261
+ interface SpawnSyncReturns<T> {
1262
+ pid: number;
1263
+ output: Array<T | null>;
1264
+ stdout: T;
1265
+ stderr: T;
1266
+ status: number | null;
1267
+ signal: NodeJS.Signals | null;
1268
+ error?: Error | undefined;
1269
+ }
1270
+ /**
1271
+ * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
1272
+ * until the child process has fully closed. When a timeout has been encountered
1273
+ * and `killSignal` is sent, the method won't return until the process has
1274
+ * completely exited. If the process intercepts and handles the `SIGTERM` signal
1275
+ * and doesn't exit, the parent process will wait until the child process has
1276
+ * exited.
1277
+ *
1278
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1279
+ * **function. Any input containing shell metacharacters may be used to trigger**
1280
+ * **arbitrary command execution.**
1281
+ * @since v0.11.12
1282
+ * @param command The command to run.
1283
+ * @param args List of string arguments.
1284
+ */
1285
+ function spawnSync(command: string): SpawnSyncReturns<Buffer>;
1286
+ function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1287
+ function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1288
+ function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
1289
+ function spawnSync(command: string, args: ReadonlyArray<string>): SpawnSyncReturns<Buffer>;
1290
+ function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1291
+ function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1292
+ function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
1293
+ interface CommonExecOptions extends CommonOptions {
1294
+ input?: string | NodeJS.ArrayBufferView | undefined;
1295
+ stdio?: StdioOptions | undefined;
1296
+ killSignal?: NodeJS.Signals | number | undefined;
1297
+ maxBuffer?: number | undefined;
1298
+ encoding?: BufferEncoding | 'buffer' | null | undefined;
1299
+ }
1300
+ interface ExecSyncOptions extends CommonExecOptions {
1301
+ shell?: string | undefined;
1302
+ }
1303
+ interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1304
+ encoding: BufferEncoding;
1305
+ }
1306
+ interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1307
+ encoding?: 'buffer' | null | undefined;
1308
+ }
1309
+ /**
1310
+ * The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
1311
+ * until the child process has fully closed. When a timeout has been encountered
1312
+ * and `killSignal` is sent, the method won't return until the process has
1313
+ * completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process
1314
+ * has exited.
1315
+ *
1316
+ * If the process times out or has a non-zero exit code, this method will throw.
1317
+ * The `Error` object will contain the entire result from {@link spawnSync}.
1318
+ *
1319
+ * **Never pass unsanitized user input to this function. Any input containing shell**
1320
+ * **metacharacters may be used to trigger arbitrary command execution.**
1321
+ * @since v0.11.12
1322
+ * @param command The command to run.
1323
+ * @return The stdout from the command.
1324
+ */
1325
+ function execSync(command: string): Buffer;
1326
+ function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
1327
+ function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
1328
+ function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
1329
+ interface ExecFileSyncOptions extends CommonExecOptions {
1330
+ shell?: boolean | string | undefined;
1331
+ }
1332
+ interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1333
+ encoding: BufferEncoding;
1334
+ }
1335
+ interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1336
+ encoding?: 'buffer' | null; // specify `null`.
1337
+ }
1338
+ /**
1339
+ * The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
1340
+ * return until the child process has fully closed. When a timeout has been
1341
+ * encountered and `killSignal` is sent, the method won't return until the process
1342
+ * has completely exited.
1343
+ *
1344
+ * If the child process intercepts and handles the `SIGTERM` signal and
1345
+ * does not exit, the parent process will still wait until the child process has
1346
+ * exited.
1347
+ *
1348
+ * If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}.
1349
+ *
1350
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1351
+ * **function. Any input containing shell metacharacters may be used to trigger**
1352
+ * **arbitrary command execution.**
1353
+ * @since v0.11.12
1354
+ * @param file The name or path of the executable file to run.
1355
+ * @param args List of string arguments.
1356
+ * @return The stdout from the command.
1357
+ */
1358
+ function execFileSync(file: string): Buffer;
1359
+ function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
1360
+ function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1361
+ function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
1362
+ function execFileSync(file: string, args: ReadonlyArray<string>): Buffer;
1363
+ function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithStringEncoding): string;
1364
+ function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1365
+ function execFileSync(file: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): string | Buffer;
1366
+ }
1367
+ declare module 'node:child_process' {
1368
+ export * from 'child_process';
1369
+ }
node_modules/@types/node/cluster.d.ts ADDED
@@ -0,0 +1,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Clusters of Node.js processes can be used to run multiple instances of Node.js
3
+ * that can distribute workloads among their application threads. When process
4
+ * isolation is not needed, use the `worker_threads` module instead, which
5
+ * allows running multiple application threads within a single Node.js instance.
6
+ *
7
+ * The cluster module allows easy creation of child processes that all share
8
+ * server ports.
9
+ *
10
+ * ```js
11
+ * import cluster from 'cluster';
12
+ * import http from 'http';
13
+ * import { cpus } from 'os';
14
+ * import process from 'process';
15
+ *
16
+ * const numCPUs = cpus().length;
17
+ *
18
+ * if (cluster.isPrimary) {
19
+ * console.log(`Primary ${process.pid} is running`);
20
+ *
21
+ * // Fork workers.
22
+ * for (let i = 0; i < numCPUs; i++) {
23
+ * cluster.fork();
24
+ * }
25
+ *
26
+ * cluster.on('exit', (worker, code, signal) => {
27
+ * console.log(`worker ${worker.process.pid} died`);
28
+ * });
29
+ * } else {
30
+ * // Workers can share any TCP connection
31
+ * // In this case it is an HTTP server
32
+ * http.createServer((req, res) => {
33
+ * res.writeHead(200);
34
+ * res.end('hello world\n');
35
+ * }).listen(8000);
36
+ *
37
+ * console.log(`Worker ${process.pid} started`);
38
+ * }
39
+ * ```
40
+ *
41
+ * Running Node.js will now share port 8000 between the workers:
42
+ *
43
+ * ```console
44
+ * $ node server.js
45
+ * Primary 3596 is running
46
+ * Worker 4324 started
47
+ * Worker 4520 started
48
+ * Worker 6056 started
49
+ * Worker 5644 started
50
+ * ```
51
+ *
52
+ * On Windows, it is not yet possible to set up a named pipe server in a worker.
53
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/cluster.js)
54
+ */
55
+ declare module 'cluster' {
56
+ import * as child from 'node:child_process';
57
+ import EventEmitter = require('node:events');
58
+ import * as net from 'node:net';
59
+ export interface ClusterSettings {
60
+ execArgv?: string[] | undefined; // default: process.execArgv
61
+ exec?: string | undefined;
62
+ args?: string[] | undefined;
63
+ silent?: boolean | undefined;
64
+ stdio?: any[] | undefined;
65
+ uid?: number | undefined;
66
+ gid?: number | undefined;
67
+ inspectPort?: number | (() => number) | undefined;
68
+ }
69
+ export interface Address {
70
+ address: string;
71
+ port: number;
72
+ addressType: number | 'udp4' | 'udp6'; // 4, 6, -1, "udp4", "udp6"
73
+ }
74
+ /**
75
+ * A `Worker` object contains all public information and method about a worker.
76
+ * In the primary it can be obtained using `cluster.workers`. In a worker
77
+ * it can be obtained using `cluster.worker`.
78
+ * @since v0.7.0
79
+ */
80
+ export class Worker extends EventEmitter {
81
+ /**
82
+ * Each new worker is given its own unique id, this id is stored in the`id`.
83
+ *
84
+ * While a worker is alive, this is the key that indexes it in`cluster.workers`.
85
+ * @since v0.8.0
86
+ */
87
+ id: number;
88
+ /**
89
+ * All workers are created using `child_process.fork()`, the returned object
90
+ * from this function is stored as `.process`. In a worker, the global `process`is stored.
91
+ *
92
+ * See: `Child Process module`.
93
+ *
94
+ * Workers will call `process.exit(0)` if the `'disconnect'` event occurs
95
+ * on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
96
+ * accidental disconnection.
97
+ * @since v0.7.0
98
+ */
99
+ process: child.ChildProcess;
100
+ /**
101
+ * Send a message to a worker or primary, optionally with a handle.
102
+ *
103
+ * In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
104
+ *
105
+ * In a worker, this sends a message to the primary. It is identical to`process.send()`.
106
+ *
107
+ * This example will echo back all messages from the primary:
108
+ *
109
+ * ```js
110
+ * if (cluster.isPrimary) {
111
+ * const worker = cluster.fork();
112
+ * worker.send('hi there');
113
+ *
114
+ * } else if (cluster.isWorker) {
115
+ * process.on('message', (msg) => {
116
+ * process.send(msg);
117
+ * });
118
+ * }
119
+ * ```
120
+ * @since v0.7.0
121
+ * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
122
+ */
123
+ send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
124
+ send(message: child.Serializable, sendHandle: child.SendHandle, callback?: (error: Error | null) => void): boolean;
125
+ send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, callback?: (error: Error | null) => void): boolean;
126
+ /**
127
+ * This function will kill the worker. In the primary worker, it does this by
128
+ * disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
129
+ *
130
+ * The `kill()` function kills the worker process without waiting for a graceful
131
+ * disconnect, it has the same behavior as `worker.process.kill()`.
132
+ *
133
+ * This method is aliased as `worker.destroy()` for backwards compatibility.
134
+ *
135
+ * In a worker, `process.kill()` exists, but it is not this function;
136
+ * it is `kill()`.
137
+ * @since v0.9.12
138
+ * @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
139
+ */
140
+ kill(signal?: string): void;
141
+ destroy(signal?: string): void;
142
+ /**
143
+ * In a worker, this function will close all servers, wait for the `'close'` event
144
+ * on those servers, and then disconnect the IPC channel.
145
+ *
146
+ * In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
147
+ *
148
+ * Causes `.exitedAfterDisconnect` to be set.
149
+ *
150
+ * After a server is closed, it will no longer accept new connections,
151
+ * but connections may be accepted by any other listening worker. Existing
152
+ * connections will be allowed to close as usual. When no more connections exist,
153
+ * see `server.close()`, the IPC channel to the worker will close allowing it
154
+ * to die gracefully.
155
+ *
156
+ * The above applies _only_ to server connections, client connections are not
157
+ * automatically closed by workers, and disconnect does not wait for them to close
158
+ * before exiting.
159
+ *
160
+ * In a worker, `process.disconnect` exists, but it is not this function;
161
+ * it is `disconnect()`.
162
+ *
163
+ * Because long living server connections may block workers from disconnecting, it
164
+ * may be useful to send a message, so application specific actions may be taken to
165
+ * close them. It also may be useful to implement a timeout, killing a worker if
166
+ * the `'disconnect'` event has not been emitted after some time.
167
+ *
168
+ * ```js
169
+ * if (cluster.isPrimary) {
170
+ * const worker = cluster.fork();
171
+ * let timeout;
172
+ *
173
+ * worker.on('listening', (address) => {
174
+ * worker.send('shutdown');
175
+ * worker.disconnect();
176
+ * timeout = setTimeout(() => {
177
+ * worker.kill();
178
+ * }, 2000);
179
+ * });
180
+ *
181
+ * worker.on('disconnect', () => {
182
+ * clearTimeout(timeout);
183
+ * });
184
+ *
185
+ * } else if (cluster.isWorker) {
186
+ * const net = require('net');
187
+ * const server = net.createServer((socket) => {
188
+ * // Connections never end
189
+ * });
190
+ *
191
+ * server.listen(8000);
192
+ *
193
+ * process.on('message', (msg) => {
194
+ * if (msg === 'shutdown') {
195
+ * // Initiate graceful close of any connections to server
196
+ * }
197
+ * });
198
+ * }
199
+ * ```
200
+ * @since v0.7.7
201
+ * @return A reference to `worker`.
202
+ */
203
+ disconnect(): void;
204
+ /**
205
+ * This function returns `true` if the worker is connected to its primary via its
206
+ * IPC channel, `false` otherwise. A worker is connected to its primary after it
207
+ * has been created. It is disconnected after the `'disconnect'` event is emitted.
208
+ * @since v0.11.14
209
+ */
210
+ isConnected(): boolean;
211
+ /**
212
+ * This function returns `true` if the worker's process has terminated (either
213
+ * because of exiting or being signaled). Otherwise, it returns `false`.
214
+ *
215
+ * ```js
216
+ * import cluster from 'cluster';
217
+ * import http from 'http';
218
+ * import { cpus } from 'os';
219
+ * import process from 'process';
220
+ *
221
+ * const numCPUs = cpus().length;
222
+ *
223
+ * if (cluster.isPrimary) {
224
+ * console.log(`Primary ${process.pid} is running`);
225
+ *
226
+ * // Fork workers.
227
+ * for (let i = 0; i < numCPUs; i++) {
228
+ * cluster.fork();
229
+ * }
230
+ *
231
+ * cluster.on('fork', (worker) => {
232
+ * console.log('worker is dead:', worker.isDead());
233
+ * });
234
+ *
235
+ * cluster.on('exit', (worker, code, signal) => {
236
+ * console.log('worker is dead:', worker.isDead());
237
+ * });
238
+ * } else {
239
+ * // Workers can share any TCP connection. In this case, it is an HTTP server.
240
+ * http.createServer((req, res) => {
241
+ * res.writeHead(200);
242
+ * res.end(`Current process\n ${process.pid}`);
243
+ * process.kill(process.pid);
244
+ * }).listen(8000);
245
+ * }
246
+ * ```
247
+ * @since v0.11.14
248
+ */
249
+ isDead(): boolean;
250
+ /**
251
+ * This property is `true` if the worker exited due to `.disconnect()`.
252
+ * If the worker exited any other way, it is `false`. If the
253
+ * worker has not exited, it is `undefined`.
254
+ *
255
+ * The boolean `worker.exitedAfterDisconnect` allows distinguishing between
256
+ * voluntary and accidental exit, the primary may choose not to respawn a worker
257
+ * based on this value.
258
+ *
259
+ * ```js
260
+ * cluster.on('exit', (worker, code, signal) => {
261
+ * if (worker.exitedAfterDisconnect === true) {
262
+ * console.log('Oh, it was just voluntary – no need to worry');
263
+ * }
264
+ * });
265
+ *
266
+ * // kill worker
267
+ * worker.kill();
268
+ * ```
269
+ * @since v6.0.0
270
+ */
271
+ exitedAfterDisconnect: boolean;
272
+ /**
273
+ * events.EventEmitter
274
+ * 1. disconnect
275
+ * 2. error
276
+ * 3. exit
277
+ * 4. listening
278
+ * 5. message
279
+ * 6. online
280
+ */
281
+ addListener(event: string, listener: (...args: any[]) => void): this;
282
+ addListener(event: 'disconnect', listener: () => void): this;
283
+ addListener(event: 'error', listener: (error: Error) => void): this;
284
+ addListener(event: 'exit', listener: (code: number, signal: string) => void): this;
285
+ addListener(event: 'listening', listener: (address: Address) => void): this;
286
+ addListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
287
+ addListener(event: 'online', listener: () => void): this;
288
+ emit(event: string | symbol, ...args: any[]): boolean;
289
+ emit(event: 'disconnect'): boolean;
290
+ emit(event: 'error', error: Error): boolean;
291
+ emit(event: 'exit', code: number, signal: string): boolean;
292
+ emit(event: 'listening', address: Address): boolean;
293
+ emit(event: 'message', message: any, handle: net.Socket | net.Server): boolean;
294
+ emit(event: 'online'): boolean;
295
+ on(event: string, listener: (...args: any[]) => void): this;
296
+ on(event: 'disconnect', listener: () => void): this;
297
+ on(event: 'error', listener: (error: Error) => void): this;
298
+ on(event: 'exit', listener: (code: number, signal: string) => void): this;
299
+ on(event: 'listening', listener: (address: Address) => void): this;
300
+ on(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
301
+ on(event: 'online', listener: () => void): this;
302
+ once(event: string, listener: (...args: any[]) => void): this;
303
+ once(event: 'disconnect', listener: () => void): this;
304
+ once(event: 'error', listener: (error: Error) => void): this;
305
+ once(event: 'exit', listener: (code: number, signal: string) => void): this;
306
+ once(event: 'listening', listener: (address: Address) => void): this;
307
+ once(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
308
+ once(event: 'online', listener: () => void): this;
309
+ prependListener(event: string, listener: (...args: any[]) => void): this;
310
+ prependListener(event: 'disconnect', listener: () => void): this;
311
+ prependListener(event: 'error', listener: (error: Error) => void): this;
312
+ prependListener(event: 'exit', listener: (code: number, signal: string) => void): this;
313
+ prependListener(event: 'listening', listener: (address: Address) => void): this;
314
+ prependListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
315
+ prependListener(event: 'online', listener: () => void): this;
316
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
317
+ prependOnceListener(event: 'disconnect', listener: () => void): this;
318
+ prependOnceListener(event: 'error', listener: (error: Error) => void): this;
319
+ prependOnceListener(event: 'exit', listener: (code: number, signal: string) => void): this;
320
+ prependOnceListener(event: 'listening', listener: (address: Address) => void): this;
321
+ prependOnceListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
322
+ prependOnceListener(event: 'online', listener: () => void): this;
323
+ }
324
+ export interface Cluster extends EventEmitter {
325
+ disconnect(callback?: () => void): void;
326
+ fork(env?: any): Worker;
327
+ /** @deprecated since v16.0.0 - use isPrimary. */
328
+ readonly isMaster: boolean;
329
+ readonly isPrimary: boolean;
330
+ readonly isWorker: boolean;
331
+ schedulingPolicy: number;
332
+ readonly settings: ClusterSettings;
333
+ /** @deprecated since v16.0.0 - use setupPrimary. */
334
+ setupMaster(settings?: ClusterSettings): void;
335
+ /**
336
+ * `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
337
+ */
338
+ setupPrimary(settings?: ClusterSettings): void;
339
+ readonly worker?: Worker | undefined;
340
+ readonly workers?: NodeJS.Dict<Worker> | undefined;
341
+ readonly SCHED_NONE: number;
342
+ readonly SCHED_RR: number;
343
+ /**
344
+ * events.EventEmitter
345
+ * 1. disconnect
346
+ * 2. exit
347
+ * 3. fork
348
+ * 4. listening
349
+ * 5. message
350
+ * 6. online
351
+ * 7. setup
352
+ */
353
+ addListener(event: string, listener: (...args: any[]) => void): this;
354
+ addListener(event: 'disconnect', listener: (worker: Worker) => void): this;
355
+ addListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
356
+ addListener(event: 'fork', listener: (worker: Worker) => void): this;
357
+ addListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
358
+ addListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
359
+ addListener(event: 'online', listener: (worker: Worker) => void): this;
360
+ addListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
361
+ emit(event: string | symbol, ...args: any[]): boolean;
362
+ emit(event: 'disconnect', worker: Worker): boolean;
363
+ emit(event: 'exit', worker: Worker, code: number, signal: string): boolean;
364
+ emit(event: 'fork', worker: Worker): boolean;
365
+ emit(event: 'listening', worker: Worker, address: Address): boolean;
366
+ emit(event: 'message', worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
367
+ emit(event: 'online', worker: Worker): boolean;
368
+ emit(event: 'setup', settings: ClusterSettings): boolean;
369
+ on(event: string, listener: (...args: any[]) => void): this;
370
+ on(event: 'disconnect', listener: (worker: Worker) => void): this;
371
+ on(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
372
+ on(event: 'fork', listener: (worker: Worker) => void): this;
373
+ on(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
374
+ on(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
375
+ on(event: 'online', listener: (worker: Worker) => void): this;
376
+ on(event: 'setup', listener: (settings: ClusterSettings) => void): this;
377
+ once(event: string, listener: (...args: any[]) => void): this;
378
+ once(event: 'disconnect', listener: (worker: Worker) => void): this;
379
+ once(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
380
+ once(event: 'fork', listener: (worker: Worker) => void): this;
381
+ once(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
382
+ once(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
383
+ once(event: 'online', listener: (worker: Worker) => void): this;
384
+ once(event: 'setup', listener: (settings: ClusterSettings) => void): this;
385
+ prependListener(event: string, listener: (...args: any[]) => void): this;
386
+ prependListener(event: 'disconnect', listener: (worker: Worker) => void): this;
387
+ prependListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
388
+ prependListener(event: 'fork', listener: (worker: Worker) => void): this;
389
+ prependListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
390
+ // the handle is a net.Socket or net.Server object, or undefined.
391
+ prependListener(event: 'message', listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void): this;
392
+ prependListener(event: 'online', listener: (worker: Worker) => void): this;
393
+ prependListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
394
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
395
+ prependOnceListener(event: 'disconnect', listener: (worker: Worker) => void): this;
396
+ prependOnceListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
397
+ prependOnceListener(event: 'fork', listener: (worker: Worker) => void): this;
398
+ prependOnceListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
399
+ // the handle is a net.Socket or net.Server object, or undefined.
400
+ prependOnceListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
401
+ prependOnceListener(event: 'online', listener: (worker: Worker) => void): this;
402
+ prependOnceListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
403
+ }
404
+ const cluster: Cluster;
405
+ export default cluster;
406
+ }
407
+ declare module 'node:cluster' {
408
+ export * from 'cluster';
409
+ export { default as default } from 'cluster';
410
+ }
node_modules/@types/node/console.d.ts ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `console` module provides a simple debugging console that is similar to the
3
+ * JavaScript console mechanism provided by web browsers.
4
+ *
5
+ * The module exports two specific components:
6
+ *
7
+ * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
8
+ * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
9
+ *
10
+ * _**Warning**_: The global console object's methods are neither consistently
11
+ * synchronous like the browser APIs they resemble, nor are they consistently
12
+ * asynchronous like all other Node.js streams. See the `note on process I/O` for
13
+ * more information.
14
+ *
15
+ * Example using the global `console`:
16
+ *
17
+ * ```js
18
+ * console.log('hello world');
19
+ * // Prints: hello world, to stdout
20
+ * console.log('hello %s', 'world');
21
+ * // Prints: hello world, to stdout
22
+ * console.error(new Error('Whoops, something bad happened'));
23
+ * // Prints error message and stack trace to stderr:
24
+ * // Error: Whoops, something bad happened
25
+ * // at [eval]:5:15
26
+ * // at Script.runInThisContext (node:vm:132:18)
27
+ * // at Object.runInThisContext (node:vm:309:38)
28
+ * // at node:internal/process/execution:77:19
29
+ * // at [eval]-wrapper:6:22
30
+ * // at evalScript (node:internal/process/execution:76:60)
31
+ * // at node:internal/main/eval_string:23:3
32
+ *
33
+ * const name = 'Will Robinson';
34
+ * console.warn(`Danger ${name}! Danger!`);
35
+ * // Prints: Danger Will Robinson! Danger!, to stderr
36
+ * ```
37
+ *
38
+ * Example using the `Console` class:
39
+ *
40
+ * ```js
41
+ * const out = getStreamSomehow();
42
+ * const err = getStreamSomehow();
43
+ * const myConsole = new console.Console(out, err);
44
+ *
45
+ * myConsole.log('hello world');
46
+ * // Prints: hello world, to out
47
+ * myConsole.log('hello %s', 'world');
48
+ * // Prints: hello world, to out
49
+ * myConsole.error(new Error('Whoops, something bad happened'));
50
+ * // Prints: [Error: Whoops, something bad happened], to err
51
+ *
52
+ * const name = 'Will Robinson';
53
+ * myConsole.warn(`Danger ${name}! Danger!`);
54
+ * // Prints: Danger Will Robinson! Danger!, to err
55
+ * ```
56
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js)
57
+ */
58
+ declare module 'console' {
59
+ import console = require('node:console');
60
+ export = console;
61
+ }
62
+ declare module 'node:console' {
63
+ import { InspectOptions } from 'node:util';
64
+ global {
65
+ // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
66
+ interface Console {
67
+ Console: console.ConsoleConstructor;
68
+ /**
69
+ * `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
70
+ * writes a message and does not otherwise affect execution. The output always
71
+ * starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
72
+ *
73
+ * If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
74
+ *
75
+ * ```js
76
+ * console.assert(true, 'does nothing');
77
+ *
78
+ * console.assert(false, 'Whoops %s work', 'didn\'t');
79
+ * // Assertion failed: Whoops didn't work
80
+ *
81
+ * console.assert();
82
+ * // Assertion failed
83
+ * ```
84
+ * @since v0.1.101
85
+ * @param value The value tested for being truthy.
86
+ * @param message All arguments besides `value` are used as error message.
87
+ */
88
+ assert(value: any, message?: string, ...optionalParams: any[]): void;
89
+ /**
90
+ * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
91
+ * TTY. When `stdout` is not a TTY, this method does nothing.
92
+ *
93
+ * The specific operation of `console.clear()` can vary across operating systems
94
+ * and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
95
+ * current terminal viewport for the Node.js
96
+ * binary.
97
+ * @since v8.3.0
98
+ */
99
+ clear(): void;
100
+ /**
101
+ * Maintains an internal counter specific to `label` and outputs to `stdout` the
102
+ * number of times `console.count()` has been called with the given `label`.
103
+ *
104
+ * ```js
105
+ * > console.count()
106
+ * default: 1
107
+ * undefined
108
+ * > console.count('default')
109
+ * default: 2
110
+ * undefined
111
+ * > console.count('abc')
112
+ * abc: 1
113
+ * undefined
114
+ * > console.count('xyz')
115
+ * xyz: 1
116
+ * undefined
117
+ * > console.count('abc')
118
+ * abc: 2
119
+ * undefined
120
+ * > console.count()
121
+ * default: 3
122
+ * undefined
123
+ * >
124
+ * ```
125
+ * @since v8.3.0
126
+ * @param label The display label for the counter.
127
+ */
128
+ count(label?: string): void;
129
+ /**
130
+ * Resets the internal counter specific to `label`.
131
+ *
132
+ * ```js
133
+ * > console.count('abc');
134
+ * abc: 1
135
+ * undefined
136
+ * > console.countReset('abc');
137
+ * undefined
138
+ * > console.count('abc');
139
+ * abc: 1
140
+ * undefined
141
+ * >
142
+ * ```
143
+ * @since v8.3.0
144
+ * @param label The display label for the counter.
145
+ */
146
+ countReset(label?: string): void;
147
+ /**
148
+ * The `console.debug()` function is an alias for {@link log}.
149
+ * @since v8.0.0
150
+ */
151
+ debug(message?: any, ...optionalParams: any[]): void;
152
+ /**
153
+ * Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
154
+ * This function bypasses any custom `inspect()` function defined on `obj`.
155
+ * @since v0.1.101
156
+ */
157
+ dir(obj: any, options?: InspectOptions): void;
158
+ /**
159
+ * This method calls `console.log()` passing it the arguments received.
160
+ * This method does not produce any XML formatting.
161
+ * @since v8.0.0
162
+ */
163
+ dirxml(...data: any[]): void;
164
+ /**
165
+ * Prints to `stderr` with newline. Multiple arguments can be passed, with the
166
+ * first used as the primary message and all additional used as substitution
167
+ * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
168
+ *
169
+ * ```js
170
+ * const code = 5;
171
+ * console.error('error #%d', code);
172
+ * // Prints: error #5, to stderr
173
+ * console.error('error', code);
174
+ * // Prints: error 5, to stderr
175
+ * ```
176
+ *
177
+ * If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
178
+ * values are concatenated. See `util.format()` for more information.
179
+ * @since v0.1.100
180
+ */
181
+ error(message?: any, ...optionalParams: any[]): void;
182
+ /**
183
+ * Increases indentation of subsequent lines by spaces for `groupIndentation`length.
184
+ *
185
+ * If one or more `label`s are provided, those are printed first without the
186
+ * additional indentation.
187
+ * @since v8.5.0
188
+ */
189
+ group(...label: any[]): void;
190
+ /**
191
+ * An alias for {@link group}.
192
+ * @since v8.5.0
193
+ */
194
+ groupCollapsed(...label: any[]): void;
195
+ /**
196
+ * Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
197
+ * @since v8.5.0
198
+ */
199
+ groupEnd(): void;
200
+ /**
201
+ * The `console.info()` function is an alias for {@link log}.
202
+ * @since v0.1.100
203
+ */
204
+ info(message?: any, ...optionalParams: any[]): void;
205
+ /**
206
+ * Prints to `stdout` with newline. Multiple arguments can be passed, with the
207
+ * first used as the primary message and all additional used as substitution
208
+ * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
209
+ *
210
+ * ```js
211
+ * const count = 5;
212
+ * console.log('count: %d', count);
213
+ * // Prints: count: 5, to stdout
214
+ * console.log('count:', count);
215
+ * // Prints: count: 5, to stdout
216
+ * ```
217
+ *
218
+ * See `util.format()` for more information.
219
+ * @since v0.1.100
220
+ */
221
+ log(message?: any, ...optionalParams: any[]): void;
222
+ /**
223
+ * Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
224
+ * logging the argument if it can’t be parsed as tabular.
225
+ *
226
+ * ```js
227
+ * // These can't be parsed as tabular data
228
+ * console.table(Symbol());
229
+ * // Symbol()
230
+ *
231
+ * console.table(undefined);
232
+ * // undefined
233
+ *
234
+ * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
235
+ * // ┌─────────┬─────┬─────┐
236
+ * // │ (index) │ a │ b │
237
+ * // ├─────────┼─────┼─────┤
238
+ * // │ 0 │ 1 │ 'Y' │
239
+ * // │ 1 │ 'Z' │ 2 │
240
+ * // └─────────┴─────┴─────┘
241
+ *
242
+ * console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
243
+ * // ┌─────────┬─────┐
244
+ * // │ (index) │ a │
245
+ * // ├─────────┼─────┤
246
+ * // │ 0 │ 1 │
247
+ * // │ 1 │ 'Z' │
248
+ * // └─────────┴─────┘
249
+ * ```
250
+ * @since v10.0.0
251
+ * @param properties Alternate properties for constructing the table.
252
+ */
253
+ table(tabularData: any, properties?: ReadonlyArray<string>): void;
254
+ /**
255
+ * Starts a timer that can be used to compute the duration of an operation. Timers
256
+ * are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
257
+ * suitable time units to `stdout`. For example, if the elapsed
258
+ * time is 3869ms, `console.timeEnd()` displays "3.869s".
259
+ * @since v0.1.104
260
+ */
261
+ time(label?: string): void;
262
+ /**
263
+ * Stops a timer that was previously started by calling {@link time} and
264
+ * prints the result to `stdout`:
265
+ *
266
+ * ```js
267
+ * console.time('100-elements');
268
+ * for (let i = 0; i < 100; i++) {}
269
+ * console.timeEnd('100-elements');
270
+ * // prints 100-elements: 225.438ms
271
+ * ```
272
+ * @since v0.1.104
273
+ */
274
+ timeEnd(label?: string): void;
275
+ /**
276
+ * For a timer that was previously started by calling {@link time}, prints
277
+ * the elapsed time and other `data` arguments to `stdout`:
278
+ *
279
+ * ```js
280
+ * console.time('process');
281
+ * const value = expensiveProcess1(); // Returns 42
282
+ * console.timeLog('process', value);
283
+ * // Prints "process: 365.227ms 42".
284
+ * doExpensiveProcess2(value);
285
+ * console.timeEnd('process');
286
+ * ```
287
+ * @since v10.7.0
288
+ */
289
+ timeLog(label?: string, ...data: any[]): void;
290
+ /**
291
+ * Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
292
+ *
293
+ * ```js
294
+ * console.trace('Show me');
295
+ * // Prints: (stack trace will vary based on where trace is called)
296
+ * // Trace: Show me
297
+ * // at repl:2:9
298
+ * // at REPLServer.defaultEval (repl.js:248:27)
299
+ * // at bound (domain.js:287:14)
300
+ * // at REPLServer.runBound [as eval] (domain.js:300:12)
301
+ * // at REPLServer.<anonymous> (repl.js:412:12)
302
+ * // at emitOne (events.js:82:20)
303
+ * // at REPLServer.emit (events.js:169:7)
304
+ * // at REPLServer.Interface._onLine (readline.js:210:10)
305
+ * // at REPLServer.Interface._line (readline.js:549:8)
306
+ * // at REPLServer.Interface._ttyWrite (readline.js:826:14)
307
+ * ```
308
+ * @since v0.1.104
309
+ */
310
+ trace(message?: any, ...optionalParams: any[]): void;
311
+ /**
312
+ * The `console.warn()` function is an alias for {@link error}.
313
+ * @since v0.1.100
314
+ */
315
+ warn(message?: any, ...optionalParams: any[]): void;
316
+ // --- Inspector mode only ---
317
+ /**
318
+ * This method does not display anything unless used in the inspector.
319
+ * Starts a JavaScript CPU profile with an optional label.
320
+ */
321
+ profile(label?: string): void;
322
+ /**
323
+ * This method does not display anything unless used in the inspector.
324
+ * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
325
+ */
326
+ profileEnd(label?: string): void;
327
+ /**
328
+ * This method does not display anything unless used in the inspector.
329
+ * Adds an event with the label `label` to the Timeline panel of the inspector.
330
+ */
331
+ timeStamp(label?: string): void;
332
+ }
333
+ /**
334
+ * The `console` module provides a simple debugging console that is similar to the
335
+ * JavaScript console mechanism provided by web browsers.
336
+ *
337
+ * The module exports two specific components:
338
+ *
339
+ * * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
340
+ * * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
341
+ *
342
+ * _**Warning**_: The global console object's methods are neither consistently
343
+ * synchronous like the browser APIs they resemble, nor are they consistently
344
+ * asynchronous like all other Node.js streams. See the `note on process I/O` for
345
+ * more information.
346
+ *
347
+ * Example using the global `console`:
348
+ *
349
+ * ```js
350
+ * console.log('hello world');
351
+ * // Prints: hello world, to stdout
352
+ * console.log('hello %s', 'world');
353
+ * // Prints: hello world, to stdout
354
+ * console.error(new Error('Whoops, something bad happened'));
355
+ * // Prints error message and stack trace to stderr:
356
+ * // Error: Whoops, something bad happened
357
+ * // at [eval]:5:15
358
+ * // at Script.runInThisContext (node:vm:132:18)
359
+ * // at Object.runInThisContext (node:vm:309:38)
360
+ * // at node:internal/process/execution:77:19
361
+ * // at [eval]-wrapper:6:22
362
+ * // at evalScript (node:internal/process/execution:76:60)
363
+ * // at node:internal/main/eval_string:23:3
364
+ *
365
+ * const name = 'Will Robinson';
366
+ * console.warn(`Danger ${name}! Danger!`);
367
+ * // Prints: Danger Will Robinson! Danger!, to stderr
368
+ * ```
369
+ *
370
+ * Example using the `Console` class:
371
+ *
372
+ * ```js
373
+ * const out = getStreamSomehow();
374
+ * const err = getStreamSomehow();
375
+ * const myConsole = new console.Console(out, err);
376
+ *
377
+ * myConsole.log('hello world');
378
+ * // Prints: hello world, to out
379
+ * myConsole.log('hello %s', 'world');
380
+ * // Prints: hello world, to out
381
+ * myConsole.error(new Error('Whoops, something bad happened'));
382
+ * // Prints: [Error: Whoops, something bad happened], to err
383
+ *
384
+ * const name = 'Will Robinson';
385
+ * myConsole.warn(`Danger ${name}! Danger!`);
386
+ * // Prints: Danger Will Robinson! Danger!, to err
387
+ * ```
388
+ * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
389
+ */
390
+ namespace console {
391
+ interface ConsoleConstructorOptions {
392
+ stdout: NodeJS.WritableStream;
393
+ stderr?: NodeJS.WritableStream | undefined;
394
+ ignoreErrors?: boolean | undefined;
395
+ colorMode?: boolean | 'auto' | undefined;
396
+ inspectOptions?: InspectOptions | undefined;
397
+ /**
398
+ * Set group indentation
399
+ * @default 2
400
+ */
401
+ groupIndentation?: number | undefined;
402
+ }
403
+ interface ConsoleConstructor {
404
+ prototype: Console;
405
+ new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
406
+ new (options: ConsoleConstructorOptions): Console;
407
+ }
408
+ }
409
+ var console: Console;
410
+ }
411
+ export = globalThis.console;
412
+ }
node_modules/@types/node/constants.d.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
2
+ declare module 'constants' {
3
+ import { constants as osConstants, SignalConstants } from 'node:os';
4
+ import { constants as cryptoConstants } from 'node:crypto';
5
+ import { constants as fsConstants } from 'node:fs';
6
+
7
+ const exp: typeof osConstants.errno &
8
+ typeof osConstants.priority &
9
+ SignalConstants &
10
+ typeof cryptoConstants &
11
+ typeof fsConstants;
12
+ export = exp;
13
+ }
14
+
15
+ declare module 'node:constants' {
16
+ import constants = require('constants');
17
+ export = constants;
18
+ }
node_modules/@types/node/crypto.d.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@types/node/dgram.d.ts ADDED
@@ -0,0 +1,545 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `dgram` module provides an implementation of UDP datagram sockets.
3
+ *
4
+ * ```js
5
+ * import dgram from 'dgram';
6
+ *
7
+ * const server = dgram.createSocket('udp4');
8
+ *
9
+ * server.on('error', (err) => {
10
+ * console.log(`server error:\n${err.stack}`);
11
+ * server.close();
12
+ * });
13
+ *
14
+ * server.on('message', (msg, rinfo) => {
15
+ * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
16
+ * });
17
+ *
18
+ * server.on('listening', () => {
19
+ * const address = server.address();
20
+ * console.log(`server listening ${address.address}:${address.port}`);
21
+ * });
22
+ *
23
+ * server.bind(41234);
24
+ * // Prints: server listening 0.0.0.0:41234
25
+ * ```
26
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dgram.js)
27
+ */
28
+ declare module 'dgram' {
29
+ import { AddressInfo } from 'node:net';
30
+ import * as dns from 'node:dns';
31
+ import { EventEmitter, Abortable } from 'node:events';
32
+ interface RemoteInfo {
33
+ address: string;
34
+ family: 'IPv4' | 'IPv6';
35
+ port: number;
36
+ size: number;
37
+ }
38
+ interface BindOptions {
39
+ port?: number | undefined;
40
+ address?: string | undefined;
41
+ exclusive?: boolean | undefined;
42
+ fd?: number | undefined;
43
+ }
44
+ type SocketType = 'udp4' | 'udp6';
45
+ interface SocketOptions extends Abortable {
46
+ type: SocketType;
47
+ reuseAddr?: boolean | undefined;
48
+ /**
49
+ * @default false
50
+ */
51
+ ipv6Only?: boolean | undefined;
52
+ recvBufferSize?: number | undefined;
53
+ sendBufferSize?: number | undefined;
54
+ lookup?: ((hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void) | undefined;
55
+ }
56
+ /**
57
+ * Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
58
+ * messages. When `address` and `port` are not passed to `socket.bind()` the
59
+ * method will bind the socket to the "all interfaces" address on a random port
60
+ * (it does the right thing for both `udp4` and `udp6` sockets). The bound address
61
+ * and port can be retrieved using `socket.address().address` and `socket.address().port`.
62
+ *
63
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
64
+ *
65
+ * ```js
66
+ * const controller = new AbortController();
67
+ * const { signal } = controller;
68
+ * const server = dgram.createSocket({ type: 'udp4', signal });
69
+ * server.on('message', (msg, rinfo) => {
70
+ * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
71
+ * });
72
+ * // Later, when you want to close the server.
73
+ * controller.abort();
74
+ * ```
75
+ * @since v0.11.13
76
+ * @param options Available options are:
77
+ * @param callback Attached as a listener for `'message'` events. Optional.
78
+ */
79
+ function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
80
+ function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
81
+ /**
82
+ * Encapsulates the datagram functionality.
83
+ *
84
+ * New instances of `dgram.Socket` are created using {@link createSocket}.
85
+ * The `new` keyword is not to be used to create `dgram.Socket` instances.
86
+ * @since v0.1.99
87
+ */
88
+ class Socket extends EventEmitter {
89
+ /**
90
+ * Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
91
+ * specified, the operating system will choose
92
+ * one interface and will add membership to it. To add membership to every
93
+ * available interface, call `addMembership` multiple times, once per interface.
94
+ *
95
+ * When called on an unbound socket, this method will implicitly bind to a random
96
+ * port, listening on all interfaces.
97
+ *
98
+ * When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
99
+ *
100
+ * ```js
101
+ * import cluster from 'cluster';
102
+ * import dgram from 'dgram';
103
+ *
104
+ * if (cluster.isPrimary) {
105
+ * cluster.fork(); // Works ok.
106
+ * cluster.fork(); // Fails with EADDRINUSE.
107
+ * } else {
108
+ * const s = dgram.createSocket('udp4');
109
+ * s.bind(1234, () => {
110
+ * s.addMembership('224.0.0.114');
111
+ * });
112
+ * }
113
+ * ```
114
+ * @since v0.6.9
115
+ */
116
+ addMembership(multicastAddress: string, multicastInterface?: string): void;
117
+ /**
118
+ * Returns an object containing the address information for a socket.
119
+ * For UDP sockets, this object will contain `address`, `family` and `port`properties.
120
+ *
121
+ * This method throws `EBADF` if called on an unbound socket.
122
+ * @since v0.1.99
123
+ */
124
+ address(): AddressInfo;
125
+ /**
126
+ * For UDP sockets, causes the `dgram.Socket` to listen for datagram
127
+ * messages on a named `port` and optional `address`. If `port` is not
128
+ * specified or is `0`, the operating system will attempt to bind to a
129
+ * random port. If `address` is not specified, the operating system will
130
+ * attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
131
+ * called.
132
+ *
133
+ * Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
134
+ * useful.
135
+ *
136
+ * A bound datagram socket keeps the Node.js process running to receive
137
+ * datagram messages.
138
+ *
139
+ * If binding fails, an `'error'` event is generated. In rare case (e.g.
140
+ * attempting to bind with a closed socket), an `Error` may be thrown.
141
+ *
142
+ * Example of a UDP server listening on port 41234:
143
+ *
144
+ * ```js
145
+ * import dgram from 'dgram';
146
+ *
147
+ * const server = dgram.createSocket('udp4');
148
+ *
149
+ * server.on('error', (err) => {
150
+ * console.log(`server error:\n${err.stack}`);
151
+ * server.close();
152
+ * });
153
+ *
154
+ * server.on('message', (msg, rinfo) => {
155
+ * console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
156
+ * });
157
+ *
158
+ * server.on('listening', () => {
159
+ * const address = server.address();
160
+ * console.log(`server listening ${address.address}:${address.port}`);
161
+ * });
162
+ *
163
+ * server.bind(41234);
164
+ * // Prints: server listening 0.0.0.0:41234
165
+ * ```
166
+ * @since v0.1.99
167
+ * @param callback with no parameters. Called when binding is complete.
168
+ */
169
+ bind(port?: number, address?: string, callback?: () => void): this;
170
+ bind(port?: number, callback?: () => void): this;
171
+ bind(callback?: () => void): this;
172
+ bind(options: BindOptions, callback?: () => void): this;
173
+ /**
174
+ * Close the underlying socket and stop listening for data on it. If a callback is
175
+ * provided, it is added as a listener for the `'close'` event.
176
+ * @since v0.1.99
177
+ * @param callback Called when the socket has been closed.
178
+ */
179
+ close(callback?: () => void): this;
180
+ /**
181
+ * Associates the `dgram.Socket` to a remote address and port. Every
182
+ * message sent by this handle is automatically sent to that destination. Also,
183
+ * the socket will only receive messages from that remote peer.
184
+ * Trying to call `connect()` on an already connected socket will result
185
+ * in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
186
+ * provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
187
+ * will be used by default. Once the connection is complete, a `'connect'` event
188
+ * is emitted and the optional `callback` function is called. In case of failure,
189
+ * the `callback` is called or, failing this, an `'error'` event is emitted.
190
+ * @since v12.0.0
191
+ * @param callback Called when the connection is completed or on error.
192
+ */
193
+ connect(port: number, address?: string, callback?: () => void): void;
194
+ connect(port: number, callback: () => void): void;
195
+ /**
196
+ * A synchronous function that disassociates a connected `dgram.Socket` from
197
+ * its remote address. Trying to call `disconnect()` on an unbound or already
198
+ * disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
199
+ * @since v12.0.0
200
+ */
201
+ disconnect(): void;
202
+ /**
203
+ * Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
204
+ * kernel when the socket is closed or the process terminates, so most apps will
205
+ * never have reason to call this.
206
+ *
207
+ * If `multicastInterface` is not specified, the operating system will attempt to
208
+ * drop membership on all valid interfaces.
209
+ * @since v0.6.9
210
+ */
211
+ dropMembership(multicastAddress: string, multicastInterface?: string): void;
212
+ /**
213
+ * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
214
+ * @since v8.7.0
215
+ * @return the `SO_RCVBUF` socket receive buffer size in bytes.
216
+ */
217
+ getRecvBufferSize(): number;
218
+ /**
219
+ * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
220
+ * @since v8.7.0
221
+ * @return the `SO_SNDBUF` socket send buffer size in bytes.
222
+ */
223
+ getSendBufferSize(): number;
224
+ /**
225
+ * By default, binding a socket will cause it to block the Node.js process from
226
+ * exiting as long as the socket is open. The `socket.unref()` method can be used
227
+ * to exclude the socket from the reference counting that keeps the Node.js
228
+ * process active. The `socket.ref()` method adds the socket back to the reference
229
+ * counting and restores the default behavior.
230
+ *
231
+ * Calling `socket.ref()` multiples times will have no additional effect.
232
+ *
233
+ * The `socket.ref()` method returns a reference to the socket so calls can be
234
+ * chained.
235
+ * @since v0.9.1
236
+ */
237
+ ref(): this;
238
+ /**
239
+ * Returns an object containing the `address`, `family`, and `port` of the remote
240
+ * endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
241
+ * if the socket is not connected.
242
+ * @since v12.0.0
243
+ */
244
+ remoteAddress(): AddressInfo;
245
+ /**
246
+ * Broadcasts a datagram on the socket.
247
+ * For connectionless sockets, the destination `port` and `address` must be
248
+ * specified. Connected sockets, on the other hand, will use their associated
249
+ * remote endpoint, so the `port` and `address` arguments must not be set.
250
+ *
251
+ * The `msg` argument contains the message to be sent.
252
+ * Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
253
+ * any `TypedArray` or a `DataView`,
254
+ * the `offset` and `length` specify the offset within the `Buffer` where the
255
+ * message begins and the number of bytes in the message, respectively.
256
+ * If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that
257
+ * contain multi-byte characters, `offset` and `length` will be calculated with
258
+ * respect to `byte length` and not the character position.
259
+ * If `msg` is an array, `offset` and `length` must not be specified.
260
+ *
261
+ * The `address` argument is a string. If the value of `address` is a host name,
262
+ * DNS will be used to resolve the address of the host. If `address` is not
263
+ * provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
264
+ *
265
+ * If the socket has not been previously bound with a call to `bind`, the socket
266
+ * is assigned a random port number and is bound to the "all interfaces" address
267
+ * (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
268
+ *
269
+ * An optional `callback` function may be specified to as a way of reporting
270
+ * DNS errors or for determining when it is safe to reuse the `buf` object.
271
+ * DNS lookups delay the time to send for at least one tick of the
272
+ * Node.js event loop.
273
+ *
274
+ * The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be
275
+ * passed as the first argument to the `callback`. If a `callback` is not given,
276
+ * the error is emitted as an `'error'` event on the `socket` object.
277
+ *
278
+ * Offset and length are optional but both _must_ be set if either are used.
279
+ * They are supported only when the first argument is a `Buffer`, a `TypedArray`,
280
+ * or a `DataView`.
281
+ *
282
+ * This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
283
+ *
284
+ * Example of sending a UDP packet to a port on `localhost`;
285
+ *
286
+ * ```js
287
+ * import dgram from 'dgram';
288
+ * import { Buffer } from 'buffer';
289
+ *
290
+ * const message = Buffer.from('Some bytes');
291
+ * const client = dgram.createSocket('udp4');
292
+ * client.send(message, 41234, 'localhost', (err) => {
293
+ * client.close();
294
+ * });
295
+ * ```
296
+ *
297
+ * Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
298
+ *
299
+ * ```js
300
+ * import dgram from 'dgram';
301
+ * import { Buffer } from 'buffer';
302
+ *
303
+ * const buf1 = Buffer.from('Some ');
304
+ * const buf2 = Buffer.from('bytes');
305
+ * const client = dgram.createSocket('udp4');
306
+ * client.send([buf1, buf2], 41234, (err) => {
307
+ * client.close();
308
+ * });
309
+ * ```
310
+ *
311
+ * Sending multiple buffers might be faster or slower depending on the
312
+ * application and operating system. Run benchmarks to
313
+ * determine the optimal strategy on a case-by-case basis. Generally speaking,
314
+ * however, sending multiple buffers is faster.
315
+ *
316
+ * Example of sending a UDP packet using a socket connected to a port on`localhost`:
317
+ *
318
+ * ```js
319
+ * import dgram from 'dgram';
320
+ * import { Buffer } from 'buffer';
321
+ *
322
+ * const message = Buffer.from('Some bytes');
323
+ * const client = dgram.createSocket('udp4');
324
+ * client.connect(41234, 'localhost', (err) => {
325
+ * client.send(message, (err) => {
326
+ * client.close();
327
+ * });
328
+ * });
329
+ * ```
330
+ * @since v0.1.99
331
+ * @param msg Message to be sent.
332
+ * @param offset Offset in the buffer where the message starts.
333
+ * @param length Number of bytes in the message.
334
+ * @param port Destination port.
335
+ * @param address Destination host name or IP address.
336
+ * @param callback Called when the message has been sent.
337
+ */
338
+ send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
339
+ send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
340
+ send(msg: string | Uint8Array | ReadonlyArray<any>, callback?: (error: Error | null, bytes: number) => void): void;
341
+ send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
342
+ send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
343
+ send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
344
+ /**
345
+ * Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
346
+ * packets may be sent to a local interface's broadcast address.
347
+ *
348
+ * This method throws `EBADF` if called on an unbound socket.
349
+ * @since v0.6.9
350
+ */
351
+ setBroadcast(flag: boolean): void;
352
+ /**
353
+ * _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
354
+ * 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
355
+ * _with a scope index is written as `'IP%scope'` where scope is an interface name_
356
+ * _or interface number._
357
+ *
358
+ * Sets the default outgoing multicast interface of the socket to a chosen
359
+ * interface or back to system interface selection. The `multicastInterface` must
360
+ * be a valid string representation of an IP from the socket's family.
361
+ *
362
+ * For IPv4 sockets, this should be the IP configured for the desired physical
363
+ * interface. All packets sent to multicast on the socket will be sent on the
364
+ * interface determined by the most recent successful use of this call.
365
+ *
366
+ * For IPv6 sockets, `multicastInterface` should include a scope to indicate the
367
+ * interface as in the examples that follow. In IPv6, individual `send` calls can
368
+ * also use explicit scope in addresses, so only packets sent to a multicast
369
+ * address without specifying an explicit scope are affected by the most recent
370
+ * successful use of this call.
371
+ *
372
+ * This method throws `EBADF` if called on an unbound socket.
373
+ *
374
+ * #### Example: IPv6 outgoing multicast interface
375
+ *
376
+ * On most systems, where scope format uses the interface name:
377
+ *
378
+ * ```js
379
+ * const socket = dgram.createSocket('udp6');
380
+ *
381
+ * socket.bind(1234, () => {
382
+ * socket.setMulticastInterface('::%eth1');
383
+ * });
384
+ * ```
385
+ *
386
+ * On Windows, where scope format uses an interface number:
387
+ *
388
+ * ```js
389
+ * const socket = dgram.createSocket('udp6');
390
+ *
391
+ * socket.bind(1234, () => {
392
+ * socket.setMulticastInterface('::%2');
393
+ * });
394
+ * ```
395
+ *
396
+ * #### Example: IPv4 outgoing multicast interface
397
+ *
398
+ * All systems use an IP of the host on the desired physical interface:
399
+ *
400
+ * ```js
401
+ * const socket = dgram.createSocket('udp4');
402
+ *
403
+ * socket.bind(1234, () => {
404
+ * socket.setMulticastInterface('10.0.0.2');
405
+ * });
406
+ * ```
407
+ * @since v8.6.0
408
+ */
409
+ setMulticastInterface(multicastInterface: string): void;
410
+ /**
411
+ * Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
412
+ * multicast packets will also be received on the local interface.
413
+ *
414
+ * This method throws `EBADF` if called on an unbound socket.
415
+ * @since v0.3.8
416
+ */
417
+ setMulticastLoopback(flag: boolean): boolean;
418
+ /**
419
+ * Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
420
+ * "Time to Live", in this context it specifies the number of IP hops that a
421
+ * packet is allowed to travel through, specifically for multicast traffic. Each
422
+ * router or gateway that forwards a packet decrements the TTL. If the TTL is
423
+ * decremented to 0 by a router, it will not be forwarded.
424
+ *
425
+ * The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
426
+ *
427
+ * This method throws `EBADF` if called on an unbound socket.
428
+ * @since v0.3.8
429
+ */
430
+ setMulticastTTL(ttl: number): number;
431
+ /**
432
+ * Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
433
+ * in bytes.
434
+ *
435
+ * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
436
+ * @since v8.7.0
437
+ */
438
+ setRecvBufferSize(size: number): void;
439
+ /**
440
+ * Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
441
+ * in bytes.
442
+ *
443
+ * This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
444
+ * @since v8.7.0
445
+ */
446
+ setSendBufferSize(size: number): void;
447
+ /**
448
+ * Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
449
+ * in this context it specifies the number of IP hops that a packet is allowed to
450
+ * travel through. Each router or gateway that forwards a packet decrements the
451
+ * TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
452
+ * Changing TTL values is typically done for network probes or when multicasting.
453
+ *
454
+ * The `ttl` argument may be between 1 and 255\. The default on most systems
455
+ * is 64.
456
+ *
457
+ * This method throws `EBADF` if called on an unbound socket.
458
+ * @since v0.1.101
459
+ */
460
+ setTTL(ttl: number): number;
461
+ /**
462
+ * By default, binding a socket will cause it to block the Node.js process from
463
+ * exiting as long as the socket is open. The `socket.unref()` method can be used
464
+ * to exclude the socket from the reference counting that keeps the Node.js
465
+ * process active, allowing the process to exit even if the socket is still
466
+ * listening.
467
+ *
468
+ * Calling `socket.unref()` multiple times will have no addition effect.
469
+ *
470
+ * The `socket.unref()` method returns a reference to the socket so calls can be
471
+ * chained.
472
+ * @since v0.9.1
473
+ */
474
+ unref(): this;
475
+ /**
476
+ * Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
477
+ * option. If the `multicastInterface` argument
478
+ * is not specified, the operating system will choose one interface and will add
479
+ * membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
480
+ *
481
+ * When called on an unbound socket, this method will implicitly bind to a random
482
+ * port, listening on all interfaces.
483
+ * @since v13.1.0, v12.16.0
484
+ */
485
+ addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
486
+ /**
487
+ * Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
488
+ * automatically called by the kernel when the
489
+ * socket is closed or the process terminates, so most apps will never have
490
+ * reason to call this.
491
+ *
492
+ * If `multicastInterface` is not specified, the operating system will attempt to
493
+ * drop membership on all valid interfaces.
494
+ * @since v13.1.0, v12.16.0
495
+ */
496
+ dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
497
+ /**
498
+ * events.EventEmitter
499
+ * 1. close
500
+ * 2. connect
501
+ * 3. error
502
+ * 4. listening
503
+ * 5. message
504
+ */
505
+ addListener(event: string, listener: (...args: any[]) => void): this;
506
+ addListener(event: 'close', listener: () => void): this;
507
+ addListener(event: 'connect', listener: () => void): this;
508
+ addListener(event: 'error', listener: (err: Error) => void): this;
509
+ addListener(event: 'listening', listener: () => void): this;
510
+ addListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
511
+ emit(event: string | symbol, ...args: any[]): boolean;
512
+ emit(event: 'close'): boolean;
513
+ emit(event: 'connect'): boolean;
514
+ emit(event: 'error', err: Error): boolean;
515
+ emit(event: 'listening'): boolean;
516
+ emit(event: 'message', msg: Buffer, rinfo: RemoteInfo): boolean;
517
+ on(event: string, listener: (...args: any[]) => void): this;
518
+ on(event: 'close', listener: () => void): this;
519
+ on(event: 'connect', listener: () => void): this;
520
+ on(event: 'error', listener: (err: Error) => void): this;
521
+ on(event: 'listening', listener: () => void): this;
522
+ on(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
523
+ once(event: string, listener: (...args: any[]) => void): this;
524
+ once(event: 'close', listener: () => void): this;
525
+ once(event: 'connect', listener: () => void): this;
526
+ once(event: 'error', listener: (err: Error) => void): this;
527
+ once(event: 'listening', listener: () => void): this;
528
+ once(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
529
+ prependListener(event: string, listener: (...args: any[]) => void): this;
530
+ prependListener(event: 'close', listener: () => void): this;
531
+ prependListener(event: 'connect', listener: () => void): this;
532
+ prependListener(event: 'error', listener: (err: Error) => void): this;
533
+ prependListener(event: 'listening', listener: () => void): this;
534
+ prependListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
535
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
536
+ prependOnceListener(event: 'close', listener: () => void): this;
537
+ prependOnceListener(event: 'connect', listener: () => void): this;
538
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
539
+ prependOnceListener(event: 'listening', listener: () => void): this;
540
+ prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
541
+ }
542
+ }
543
+ declare module 'node:dgram' {
544
+ export * from 'dgram';
545
+ }
node_modules/@types/node/diagnostics_channel.d.ts ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `diagnostics_channel` module provides an API to create named channels
3
+ * to report arbitrary message data for diagnostics purposes.
4
+ *
5
+ * It can be accessed using:
6
+ *
7
+ * ```js
8
+ * import diagnostics_channel from 'diagnostics_channel';
9
+ * ```
10
+ *
11
+ * It is intended that a module writer wanting to report diagnostics messages
12
+ * will create one or many top-level channels to report messages through.
13
+ * Channels may also be acquired at runtime but it is not encouraged
14
+ * due to the additional overhead of doing so. Channels may be exported for
15
+ * convenience, but as long as the name is known it can be acquired anywhere.
16
+ *
17
+ * If you intend for your module to produce diagnostics data for others to
18
+ * consume it is recommended that you include documentation of what named
19
+ * channels are used along with the shape of the message data. Channel names
20
+ * should generally include the module name to avoid collisions with data from
21
+ * other modules.
22
+ * @experimental
23
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js)
24
+ */
25
+ declare module 'diagnostics_channel' {
26
+ /**
27
+ * Check if there are active subscribers to the named channel. This is helpful if
28
+ * the message you want to send might be expensive to prepare.
29
+ *
30
+ * This API is optional but helpful when trying to publish messages from very
31
+ * performance-sensitive code.
32
+ *
33
+ * ```js
34
+ * import diagnostics_channel from 'diagnostics_channel';
35
+ *
36
+ * if (diagnostics_channel.hasSubscribers('my-channel')) {
37
+ * // There are subscribers, prepare and publish message
38
+ * }
39
+ * ```
40
+ * @since v15.1.0, v14.17.0
41
+ * @param name The channel name
42
+ * @return If there are active subscribers
43
+ */
44
+ function hasSubscribers(name: string | symbol): boolean;
45
+ /**
46
+ * This is the primary entry-point for anyone wanting to interact with a named
47
+ * channel. It produces a channel object which is optimized to reduce overhead at
48
+ * publish time as much as possible.
49
+ *
50
+ * ```js
51
+ * import diagnostics_channel from 'diagnostics_channel';
52
+ *
53
+ * const channel = diagnostics_channel.channel('my-channel');
54
+ * ```
55
+ * @since v15.1.0, v14.17.0
56
+ * @param name The channel name
57
+ * @return The named channel object
58
+ */
59
+ function channel(name: string | symbol): Channel;
60
+ type ChannelListener = (message: unknown, name: string | symbol) => void;
61
+ /**
62
+ * The class `Channel` represents an individual named channel within the data
63
+ * pipeline. It is use to track subscribers and to publish messages when there
64
+ * are subscribers present. It exists as a separate object to avoid channel
65
+ * lookups at publish time, enabling very fast publish speeds and allowing
66
+ * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
67
+ * with `new Channel(name)` is not supported.
68
+ * @since v15.1.0, v14.17.0
69
+ */
70
+ class Channel {
71
+ readonly name: string | symbol;
72
+ /**
73
+ * Check if there are active subscribers to this channel. This is helpful if
74
+ * the message you want to send might be expensive to prepare.
75
+ *
76
+ * This API is optional but helpful when trying to publish messages from very
77
+ * performance-sensitive code.
78
+ *
79
+ * ```js
80
+ * import diagnostics_channel from 'diagnostics_channel';
81
+ *
82
+ * const channel = diagnostics_channel.channel('my-channel');
83
+ *
84
+ * if (channel.hasSubscribers) {
85
+ * // There are subscribers, prepare and publish message
86
+ * }
87
+ * ```
88
+ * @since v15.1.0, v14.17.0
89
+ */
90
+ readonly hasSubscribers: boolean;
91
+ private constructor(name: string | symbol);
92
+ /**
93
+ * Publish a message to any subscribers to the channel. This will
94
+ * trigger message handlers synchronously so they will execute within
95
+ * the same context.
96
+ *
97
+ * ```js
98
+ * import diagnostics_channel from 'diagnostics_channel';
99
+ *
100
+ * const channel = diagnostics_channel.channel('my-channel');
101
+ *
102
+ * channel.publish({
103
+ * some: 'message'
104
+ * });
105
+ * ```
106
+ * @since v15.1.0, v14.17.0
107
+ * @param message The message to send to the channel subscribers
108
+ */
109
+ publish(message: unknown): void;
110
+ /**
111
+ * Register a message handler to subscribe to this channel. This message handler
112
+ * will be run synchronously whenever a message is published to the channel. Any
113
+ * errors thrown in the message handler will trigger an `'uncaughtException'`.
114
+ *
115
+ * ```js
116
+ * import diagnostics_channel from 'diagnostics_channel';
117
+ *
118
+ * const channel = diagnostics_channel.channel('my-channel');
119
+ *
120
+ * channel.subscribe((message, name) => {
121
+ * // Received data
122
+ * });
123
+ * ```
124
+ * @since v15.1.0, v14.17.0
125
+ * @param onMessage The handler to receive channel messages
126
+ */
127
+ subscribe(onMessage: ChannelListener): void;
128
+ /**
129
+ * Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
130
+ *
131
+ * ```js
132
+ * import diagnostics_channel from 'diagnostics_channel';
133
+ *
134
+ * const channel = diagnostics_channel.channel('my-channel');
135
+ *
136
+ * function onMessage(message, name) {
137
+ * // Received data
138
+ * }
139
+ *
140
+ * channel.subscribe(onMessage);
141
+ *
142
+ * channel.unsubscribe(onMessage);
143
+ * ```
144
+ * @since v15.1.0, v14.17.0
145
+ * @param onMessage The previous subscribed handler to remove
146
+ * @return `true` if the handler was found, `false` otherwise.
147
+ */
148
+ unsubscribe(onMessage: ChannelListener): void;
149
+ }
150
+ }
151
+ declare module 'node:diagnostics_channel' {
152
+ export * from 'diagnostics_channel';
153
+ }
node_modules/@types/node/dns.d.ts ADDED
@@ -0,0 +1,659 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `dns` module enables name resolution. For example, use it to look up IP
3
+ * addresses of host names.
4
+ *
5
+ * Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
6
+ * DNS protocol for lookups. {@link lookup} uses the operating system
7
+ * facilities to perform name resolution. It may not need to perform any network
8
+ * communication. To perform name resolution the way other applications on the same
9
+ * system do, use {@link lookup}.
10
+ *
11
+ * ```js
12
+ * const dns = require('dns');
13
+ *
14
+ * dns.lookup('example.org', (err, address, family) => {
15
+ * console.log('address: %j family: IPv%s', address, family);
16
+ * });
17
+ * // address: "93.184.216.34" family: IPv4
18
+ * ```
19
+ *
20
+ * All other functions in the `dns` module connect to an actual DNS server to
21
+ * perform name resolution. They will always use the network to perform DNS
22
+ * queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
23
+ * DNS queries, bypassing other name-resolution facilities.
24
+ *
25
+ * ```js
26
+ * const dns = require('dns');
27
+ *
28
+ * dns.resolve4('archive.org', (err, addresses) => {
29
+ * if (err) throw err;
30
+ *
31
+ * console.log(`addresses: ${JSON.stringify(addresses)}`);
32
+ *
33
+ * addresses.forEach((a) => {
34
+ * dns.reverse(a, (err, hostnames) => {
35
+ * if (err) {
36
+ * throw err;
37
+ * }
38
+ * console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
39
+ * });
40
+ * });
41
+ * });
42
+ * ```
43
+ *
44
+ * See the `Implementation considerations section` for more information.
45
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js)
46
+ */
47
+ declare module 'dns' {
48
+ import * as dnsPromises from 'node:dns/promises';
49
+ // Supported getaddrinfo flags.
50
+ export const ADDRCONFIG: number;
51
+ export const V4MAPPED: number;
52
+ /**
53
+ * If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
54
+ * well as IPv4 mapped IPv6 addresses.
55
+ */
56
+ export const ALL: number;
57
+ export interface LookupOptions {
58
+ family?: number | undefined;
59
+ hints?: number | undefined;
60
+ all?: boolean | undefined;
61
+ /**
62
+ * @default true
63
+ */
64
+ verbatim?: boolean | undefined;
65
+ }
66
+ export interface LookupOneOptions extends LookupOptions {
67
+ all?: false | undefined;
68
+ }
69
+ export interface LookupAllOptions extends LookupOptions {
70
+ all: true;
71
+ }
72
+ export interface LookupAddress {
73
+ address: string;
74
+ family: number;
75
+ }
76
+ /**
77
+ * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
78
+ * AAAA (IPv6) record. All `option` properties are optional. If `options` is an
79
+ * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
80
+ * and IPv6 addresses are both returned if found.
81
+ *
82
+ * With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
83
+ * properties `address` and `family`.
84
+ *
85
+ * On error, `err` is an `Error` object, where `err.code` is the error code.
86
+ * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
87
+ * the host name does not exist but also when the lookup fails in other ways
88
+ * such as no available file descriptors.
89
+ *
90
+ * `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
91
+ * The implementation uses an operating system facility that can associate names
92
+ * with addresses, and vice versa. This implementation can have subtle but
93
+ * important consequences on the behavior of any Node.js program. Please take some
94
+ * time to consult the `Implementation considerations section` before using`dns.lookup()`.
95
+ *
96
+ * Example usage:
97
+ *
98
+ * ```js
99
+ * const dns = require('dns');
100
+ * const options = {
101
+ * family: 6,
102
+ * hints: dns.ADDRCONFIG | dns.V4MAPPED,
103
+ * };
104
+ * dns.lookup('example.com', options, (err, address, family) =>
105
+ * console.log('address: %j family: IPv%s', address, family));
106
+ * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
107
+ *
108
+ * // When options.all is true, the result will be an Array.
109
+ * options.all = true;
110
+ * dns.lookup('example.com', options, (err, addresses) =>
111
+ * console.log('addresses: %j', addresses));
112
+ * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
113
+ * ```
114
+ *
115
+ * If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
116
+ * @since v0.1.90
117
+ */
118
+ export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
119
+ export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
120
+ export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
121
+ export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
122
+ export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
123
+ export namespace lookup {
124
+ function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
125
+ function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
126
+ function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
127
+ }
128
+ /**
129
+ * Resolves the given `address` and `port` into a host name and service using
130
+ * the operating system's underlying `getnameinfo` implementation.
131
+ *
132
+ * If `address` is not a valid IP address, a `TypeError` will be thrown.
133
+ * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
134
+ *
135
+ * On an error, `err` is an `Error` object, where `err.code` is the error code.
136
+ *
137
+ * ```js
138
+ * const dns = require('dns');
139
+ * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
140
+ * console.log(hostname, service);
141
+ * // Prints: localhost ssh
142
+ * });
143
+ * ```
144
+ *
145
+ * If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
146
+ * @since v0.11.14
147
+ */
148
+ export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
149
+ export namespace lookupService {
150
+ function __promisify__(
151
+ address: string,
152
+ port: number
153
+ ): Promise<{
154
+ hostname: string;
155
+ service: string;
156
+ }>;
157
+ }
158
+ export interface ResolveOptions {
159
+ ttl: boolean;
160
+ }
161
+ export interface ResolveWithTtlOptions extends ResolveOptions {
162
+ ttl: true;
163
+ }
164
+ export interface RecordWithTtl {
165
+ address: string;
166
+ ttl: number;
167
+ }
168
+ /** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
169
+ export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
170
+ export interface AnyARecord extends RecordWithTtl {
171
+ type: 'A';
172
+ }
173
+ export interface AnyAaaaRecord extends RecordWithTtl {
174
+ type: 'AAAA';
175
+ }
176
+ export interface CaaRecord {
177
+ critial: number;
178
+ issue?: string | undefined;
179
+ issuewild?: string | undefined;
180
+ iodef?: string | undefined;
181
+ contactemail?: string | undefined;
182
+ contactphone?: string | undefined;
183
+ }
184
+ export interface MxRecord {
185
+ priority: number;
186
+ exchange: string;
187
+ }
188
+ export interface AnyMxRecord extends MxRecord {
189
+ type: 'MX';
190
+ }
191
+ export interface NaptrRecord {
192
+ flags: string;
193
+ service: string;
194
+ regexp: string;
195
+ replacement: string;
196
+ order: number;
197
+ preference: number;
198
+ }
199
+ export interface AnyNaptrRecord extends NaptrRecord {
200
+ type: 'NAPTR';
201
+ }
202
+ export interface SoaRecord {
203
+ nsname: string;
204
+ hostmaster: string;
205
+ serial: number;
206
+ refresh: number;
207
+ retry: number;
208
+ expire: number;
209
+ minttl: number;
210
+ }
211
+ export interface AnySoaRecord extends SoaRecord {
212
+ type: 'SOA';
213
+ }
214
+ export interface SrvRecord {
215
+ priority: number;
216
+ weight: number;
217
+ port: number;
218
+ name: string;
219
+ }
220
+ export interface AnySrvRecord extends SrvRecord {
221
+ type: 'SRV';
222
+ }
223
+ export interface AnyTxtRecord {
224
+ type: 'TXT';
225
+ entries: string[];
226
+ }
227
+ export interface AnyNsRecord {
228
+ type: 'NS';
229
+ value: string;
230
+ }
231
+ export interface AnyPtrRecord {
232
+ type: 'PTR';
233
+ value: string;
234
+ }
235
+ export interface AnyCnameRecord {
236
+ type: 'CNAME';
237
+ value: string;
238
+ }
239
+ export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
240
+ /**
241
+ * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
242
+ * of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
243
+ * records. The type and structure of individual results varies based on `rrtype`:
244
+ *
245
+ * <omitted>
246
+ *
247
+ * On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
248
+ * @since v0.1.27
249
+ * @param hostname Host name to resolve.
250
+ * @param [rrtype='A'] Resource record type.
251
+ */
252
+ export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
253
+ export function resolve(hostname: string, rrtype: 'A', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
254
+ export function resolve(hostname: string, rrtype: 'AAAA', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
255
+ export function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
256
+ export function resolve(hostname: string, rrtype: 'CNAME', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
257
+ export function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
258
+ export function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
259
+ export function resolve(hostname: string, rrtype: 'NS', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
260
+ export function resolve(hostname: string, rrtype: 'PTR', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
261
+ export function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
262
+ export function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
263
+ export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
264
+ export function resolve(
265
+ hostname: string,
266
+ rrtype: string,
267
+ callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
268
+ ): void;
269
+ export namespace resolve {
270
+ function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
271
+ function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
272
+ function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
273
+ function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
274
+ function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
275
+ function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
276
+ function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
277
+ function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
278
+ }
279
+ /**
280
+ * Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
281
+ * will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
282
+ * @since v0.1.16
283
+ * @param hostname Host name to resolve.
284
+ */
285
+ export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
286
+ export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
287
+ export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
288
+ export namespace resolve4 {
289
+ function __promisify__(hostname: string): Promise<string[]>;
290
+ function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
291
+ function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
292
+ }
293
+ /**
294
+ * Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
295
+ * will contain an array of IPv6 addresses.
296
+ * @since v0.1.16
297
+ * @param hostname Host name to resolve.
298
+ */
299
+ export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
300
+ export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
301
+ export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
302
+ export namespace resolve6 {
303
+ function __promisify__(hostname: string): Promise<string[]>;
304
+ function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
305
+ function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
306
+ }
307
+ /**
308
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
309
+ * will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
310
+ * @since v0.3.2
311
+ */
312
+ export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
313
+ export namespace resolveCname {
314
+ function __promisify__(hostname: string): Promise<string[]>;
315
+ }
316
+ /**
317
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
318
+ * will contain an array of certification authority authorization records
319
+ * available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:[email protected]'}, {critical: 128, issue: 'pki.example.com'}]`).
320
+ * @since v15.0.0, v14.17.0
321
+ */
322
+ export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
323
+ export namespace resolveCaa {
324
+ function __promisify__(hostname: string): Promise<CaaRecord[]>;
325
+ }
326
+ /**
327
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
328
+ * contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
329
+ * @since v0.1.27
330
+ */
331
+ export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
332
+ export namespace resolveMx {
333
+ function __promisify__(hostname: string): Promise<MxRecord[]>;
334
+ }
335
+ /**
336
+ * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
337
+ * objects with the following properties:
338
+ *
339
+ * * `flags`
340
+ * * `service`
341
+ * * `regexp`
342
+ * * `replacement`
343
+ * * `order`
344
+ * * `preference`
345
+ *
346
+ * ```js
347
+ * {
348
+ * flags: 's',
349
+ * service: 'SIP+D2U',
350
+ * regexp: '',
351
+ * replacement: '_sip._udp.example.com',
352
+ * order: 30,
353
+ * preference: 100
354
+ * }
355
+ * ```
356
+ * @since v0.9.12
357
+ */
358
+ export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
359
+ export namespace resolveNaptr {
360
+ function __promisify__(hostname: string): Promise<NaptrRecord[]>;
361
+ }
362
+ /**
363
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
364
+ * contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
365
+ * @since v0.1.90
366
+ */
367
+ export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
368
+ export namespace resolveNs {
369
+ function __promisify__(hostname: string): Promise<string[]>;
370
+ }
371
+ /**
372
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
373
+ * be an array of strings containing the reply records.
374
+ * @since v6.0.0
375
+ */
376
+ export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
377
+ export namespace resolvePtr {
378
+ function __promisify__(hostname: string): Promise<string[]>;
379
+ }
380
+ /**
381
+ * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
382
+ * the `hostname`. The `address` argument passed to the `callback` function will
383
+ * be an object with the following properties:
384
+ *
385
+ * * `nsname`
386
+ * * `hostmaster`
387
+ * * `serial`
388
+ * * `refresh`
389
+ * * `retry`
390
+ * * `expire`
391
+ * * `minttl`
392
+ *
393
+ * ```js
394
+ * {
395
+ * nsname: 'ns.example.com',
396
+ * hostmaster: 'root.example.com',
397
+ * serial: 2013101809,
398
+ * refresh: 10000,
399
+ * retry: 2400,
400
+ * expire: 604800,
401
+ * minttl: 3600
402
+ * }
403
+ * ```
404
+ * @since v0.11.10
405
+ */
406
+ export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
407
+ export namespace resolveSoa {
408
+ function __promisify__(hostname: string): Promise<SoaRecord>;
409
+ }
410
+ /**
411
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
412
+ * be an array of objects with the following properties:
413
+ *
414
+ * * `priority`
415
+ * * `weight`
416
+ * * `port`
417
+ * * `name`
418
+ *
419
+ * ```js
420
+ * {
421
+ * priority: 10,
422
+ * weight: 5,
423
+ * port: 21223,
424
+ * name: 'service.example.com'
425
+ * }
426
+ * ```
427
+ * @since v0.1.27
428
+ */
429
+ export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
430
+ export namespace resolveSrv {
431
+ function __promisify__(hostname: string): Promise<SrvRecord[]>;
432
+ }
433
+ /**
434
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
435
+ * two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
436
+ * one record. Depending on the use case, these could be either joined together or
437
+ * treated separately.
438
+ * @since v0.1.27
439
+ */
440
+ export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
441
+ export namespace resolveTxt {
442
+ function __promisify__(hostname: string): Promise<string[][]>;
443
+ }
444
+ /**
445
+ * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
446
+ * The `ret` argument passed to the `callback` function will be an array containing
447
+ * various types of records. Each object has a property `type` that indicates the
448
+ * type of the current record. And depending on the `type`, additional properties
449
+ * will be present on the object:
450
+ *
451
+ * <omitted>
452
+ *
453
+ * Here is an example of the `ret` object passed to the callback:
454
+ *
455
+ * ```js
456
+ * [ { type: 'A', address: '127.0.0.1', ttl: 299 },
457
+ * { type: 'CNAME', value: 'example.com' },
458
+ * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
459
+ * { type: 'NS', value: 'ns1.example.com' },
460
+ * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
461
+ * { type: 'SOA',
462
+ * nsname: 'ns1.example.com',
463
+ * hostmaster: 'admin.example.com',
464
+ * serial: 156696742,
465
+ * refresh: 900,
466
+ * retry: 900,
467
+ * expire: 1800,
468
+ * minttl: 60 } ]
469
+ * ```
470
+ *
471
+ * DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
472
+ * 8482](https://tools.ietf.org/html/rfc8482).
473
+ */
474
+ export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
475
+ export namespace resolveAny {
476
+ function __promisify__(hostname: string): Promise<AnyRecord[]>;
477
+ }
478
+ /**
479
+ * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
480
+ * array of host names.
481
+ *
482
+ * On error, `err` is an `Error` object, where `err.code` is
483
+ * one of the `DNS error codes`.
484
+ * @since v0.1.16
485
+ */
486
+ export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
487
+ /**
488
+ * Sets the IP address and port of servers to be used when performing DNS
489
+ * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
490
+ * addresses. If the port is the IANA default DNS port (53) it can be omitted.
491
+ *
492
+ * ```js
493
+ * dns.setServers([
494
+ * '4.4.4.4',
495
+ * '[2001:4860:4860::8888]',
496
+ * '4.4.4.4:1053',
497
+ * '[2001:4860:4860::8888]:1053',
498
+ * ]);
499
+ * ```
500
+ *
501
+ * An error will be thrown if an invalid address is provided.
502
+ *
503
+ * The `dns.setServers()` method must not be called while a DNS query is in
504
+ * progress.
505
+ *
506
+ * The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
507
+ *
508
+ * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
509
+ * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
510
+ * subsequent servers provided. Fallback DNS servers will only be used if the
511
+ * earlier ones time out or result in some other error.
512
+ * @since v0.11.3
513
+ * @param servers array of `RFC 5952` formatted addresses
514
+ */
515
+ export function setServers(servers: ReadonlyArray<string>): void;
516
+ /**
517
+ * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
518
+ * that are currently configured for DNS resolution. A string will include a port
519
+ * section if a custom port is used.
520
+ *
521
+ * ```js
522
+ * [
523
+ * '4.4.4.4',
524
+ * '2001:4860:4860::8888',
525
+ * '4.4.4.4:1053',
526
+ * '[2001:4860:4860::8888]:1053',
527
+ * ]
528
+ * ```
529
+ * @since v0.11.3
530
+ */
531
+ export function getServers(): string[];
532
+ /**
533
+ * Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
534
+ *
535
+ * * `ipv4first`: sets default `verbatim` `false`.
536
+ * * `verbatim`: sets default `verbatim` `true`.
537
+ *
538
+ * The default is `ipv4first` and {@link setDefaultResultOrder} have higher
539
+ * priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default
540
+ * dns orders in workers.
541
+ * @since v16.4.0, v14.18.0
542
+ * @param order must be `'ipv4first'` or `'verbatim'`.
543
+ */
544
+ export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
545
+ // Error codes
546
+ export const NODATA: string;
547
+ export const FORMERR: string;
548
+ export const SERVFAIL: string;
549
+ export const NOTFOUND: string;
550
+ export const NOTIMP: string;
551
+ export const REFUSED: string;
552
+ export const BADQUERY: string;
553
+ export const BADNAME: string;
554
+ export const BADFAMILY: string;
555
+ export const BADRESP: string;
556
+ export const CONNREFUSED: string;
557
+ export const TIMEOUT: string;
558
+ export const EOF: string;
559
+ export const FILE: string;
560
+ export const NOMEM: string;
561
+ export const DESTRUCTION: string;
562
+ export const BADSTR: string;
563
+ export const BADFLAGS: string;
564
+ export const NONAME: string;
565
+ export const BADHINTS: string;
566
+ export const NOTINITIALIZED: string;
567
+ export const LOADIPHLPAPI: string;
568
+ export const ADDRGETNETWORKPARAMS: string;
569
+ export const CANCELLED: string;
570
+ export interface ResolverOptions {
571
+ timeout?: number | undefined;
572
+ /**
573
+ * @default 4
574
+ */
575
+ tries?: number;
576
+ }
577
+ /**
578
+ * An independent resolver for DNS requests.
579
+ *
580
+ * Creating a new resolver uses the default server settings. Setting
581
+ * the servers used for a resolver using `resolver.setServers()` does not affect
582
+ * other resolvers:
583
+ *
584
+ * ```js
585
+ * const { Resolver } = require('dns');
586
+ * const resolver = new Resolver();
587
+ * resolver.setServers(['4.4.4.4']);
588
+ *
589
+ * // This request will use the server at 4.4.4.4, independent of global settings.
590
+ * resolver.resolve4('example.org', (err, addresses) => {
591
+ * // ...
592
+ * });
593
+ * ```
594
+ *
595
+ * The following methods from the `dns` module are available:
596
+ *
597
+ * * `resolver.getServers()`
598
+ * * `resolver.resolve()`
599
+ * * `resolver.resolve4()`
600
+ * * `resolver.resolve6()`
601
+ * * `resolver.resolveAny()`
602
+ * * `resolver.resolveCaa()`
603
+ * * `resolver.resolveCname()`
604
+ * * `resolver.resolveMx()`
605
+ * * `resolver.resolveNaptr()`
606
+ * * `resolver.resolveNs()`
607
+ * * `resolver.resolvePtr()`
608
+ * * `resolver.resolveSoa()`
609
+ * * `resolver.resolveSrv()`
610
+ * * `resolver.resolveTxt()`
611
+ * * `resolver.reverse()`
612
+ * * `resolver.setServers()`
613
+ * @since v8.3.0
614
+ */
615
+ export class Resolver {
616
+ constructor(options?: ResolverOptions);
617
+ /**
618
+ * Cancel all outstanding DNS queries made by this resolver. The corresponding
619
+ * callbacks will be called with an error with code `ECANCELLED`.
620
+ * @since v8.3.0
621
+ */
622
+ cancel(): void;
623
+ getServers: typeof getServers;
624
+ resolve: typeof resolve;
625
+ resolve4: typeof resolve4;
626
+ resolve6: typeof resolve6;
627
+ resolveAny: typeof resolveAny;
628
+ resolveCname: typeof resolveCname;
629
+ resolveMx: typeof resolveMx;
630
+ resolveNaptr: typeof resolveNaptr;
631
+ resolveNs: typeof resolveNs;
632
+ resolvePtr: typeof resolvePtr;
633
+ resolveSoa: typeof resolveSoa;
634
+ resolveSrv: typeof resolveSrv;
635
+ resolveTxt: typeof resolveTxt;
636
+ reverse: typeof reverse;
637
+ /**
638
+ * The resolver instance will send its requests from the specified IP address.
639
+ * This allows programs to specify outbound interfaces when used on multi-homed
640
+ * systems.
641
+ *
642
+ * If a v4 or v6 address is not specified, it is set to the default, and the
643
+ * operating system will choose a local address automatically.
644
+ *
645
+ * The resolver will use the v4 local address when making requests to IPv4 DNS
646
+ * servers, and the v6 local address when making requests to IPv6 DNS servers.
647
+ * The `rrtype` of resolution requests has no impact on the local address used.
648
+ * @since v15.1.0, v14.17.0
649
+ * @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
650
+ * @param [ipv6='::0'] A string representation of an IPv6 address.
651
+ */
652
+ setLocalAddress(ipv4?: string, ipv6?: string): void;
653
+ setServers: typeof setServers;
654
+ }
655
+ export { dnsPromises as promises };
656
+ }
657
+ declare module 'node:dns' {
658
+ export * from 'dns';
659
+ }
node_modules/@types/node/dns/promises.d.ts ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `dns.promises` API provides an alternative set of asynchronous DNS methods
3
+ * that return `Promise` objects rather than using callbacks. The API is accessible
4
+ * via `require('dns').promises` or `require('dns/promises')`.
5
+ * @since v10.6.0
6
+ */
7
+ declare module 'dns/promises' {
8
+ import {
9
+ LookupAddress,
10
+ LookupOneOptions,
11
+ LookupAllOptions,
12
+ LookupOptions,
13
+ AnyRecord,
14
+ CaaRecord,
15
+ MxRecord,
16
+ NaptrRecord,
17
+ SoaRecord,
18
+ SrvRecord,
19
+ ResolveWithTtlOptions,
20
+ RecordWithTtl,
21
+ ResolveOptions,
22
+ ResolverOptions,
23
+ } from 'node:dns';
24
+ /**
25
+ * Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
26
+ * that are currently configured for DNS resolution. A string will include a port
27
+ * section if a custom port is used.
28
+ *
29
+ * ```js
30
+ * [
31
+ * '4.4.4.4',
32
+ * '2001:4860:4860::8888',
33
+ * '4.4.4.4:1053',
34
+ * '[2001:4860:4860::8888]:1053',
35
+ * ]
36
+ * ```
37
+ * @since v10.6.0
38
+ */
39
+ function getServers(): string[];
40
+ /**
41
+ * Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
42
+ * AAAA (IPv6) record. All `option` properties are optional. If `options` is an
43
+ * integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
44
+ * and IPv6 addresses are both returned if found.
45
+ *
46
+ * With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
47
+ *
48
+ * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
49
+ * Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
50
+ * the host name does not exist but also when the lookup fails in other ways
51
+ * such as no available file descriptors.
52
+ *
53
+ * `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
54
+ * protocol. The implementation uses an operating system facility that can
55
+ * associate names with addresses, and vice versa. This implementation can have
56
+ * subtle but important consequences on the behavior of any Node.js program. Please
57
+ * take some time to consult the `Implementation considerations section` before
58
+ * using `dnsPromises.lookup()`.
59
+ *
60
+ * Example usage:
61
+ *
62
+ * ```js
63
+ * const dns = require('dns');
64
+ * const dnsPromises = dns.promises;
65
+ * const options = {
66
+ * family: 6,
67
+ * hints: dns.ADDRCONFIG | dns.V4MAPPED,
68
+ * };
69
+ *
70
+ * dnsPromises.lookup('example.com', options).then((result) => {
71
+ * console.log('address: %j family: IPv%s', result.address, result.family);
72
+ * // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
73
+ * });
74
+ *
75
+ * // When options.all is true, the result will be an Array.
76
+ * options.all = true;
77
+ * dnsPromises.lookup('example.com', options).then((result) => {
78
+ * console.log('addresses: %j', result);
79
+ * // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
80
+ * });
81
+ * ```
82
+ * @since v10.6.0
83
+ */
84
+ function lookup(hostname: string, family: number): Promise<LookupAddress>;
85
+ function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
86
+ function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
87
+ function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
88
+ function lookup(hostname: string): Promise<LookupAddress>;
89
+ /**
90
+ * Resolves the given `address` and `port` into a host name and service using
91
+ * the operating system's underlying `getnameinfo` implementation.
92
+ *
93
+ * If `address` is not a valid IP address, a `TypeError` will be thrown.
94
+ * The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
95
+ *
96
+ * On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
97
+ *
98
+ * ```js
99
+ * const dnsPromises = require('dns').promises;
100
+ * dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
101
+ * console.log(result.hostname, result.service);
102
+ * // Prints: localhost ssh
103
+ * });
104
+ * ```
105
+ * @since v10.6.0
106
+ */
107
+ function lookupService(
108
+ address: string,
109
+ port: number
110
+ ): Promise<{
111
+ hostname: string;
112
+ service: string;
113
+ }>;
114
+ /**
115
+ * Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
116
+ * of the resource records. When successful, the `Promise` is resolved with an
117
+ * array of resource records. The type and structure of individual results vary
118
+ * based on `rrtype`:
119
+ *
120
+ * <omitted>
121
+ *
122
+ * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
123
+ * @since v10.6.0
124
+ * @param hostname Host name to resolve.
125
+ * @param [rrtype='A'] Resource record type.
126
+ */
127
+ function resolve(hostname: string): Promise<string[]>;
128
+ function resolve(hostname: string, rrtype: 'A'): Promise<string[]>;
129
+ function resolve(hostname: string, rrtype: 'AAAA'): Promise<string[]>;
130
+ function resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
131
+ function resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
132
+ function resolve(hostname: string, rrtype: 'CNAME'): Promise<string[]>;
133
+ function resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
134
+ function resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
135
+ function resolve(hostname: string, rrtype: 'NS'): Promise<string[]>;
136
+ function resolve(hostname: string, rrtype: 'PTR'): Promise<string[]>;
137
+ function resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
138
+ function resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
139
+ function resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
140
+ function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
141
+ /**
142
+ * Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
143
+ * addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
144
+ * @since v10.6.0
145
+ * @param hostname Host name to resolve.
146
+ */
147
+ function resolve4(hostname: string): Promise<string[]>;
148
+ function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
149
+ function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
150
+ /**
151
+ * Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
152
+ * addresses.
153
+ * @since v10.6.0
154
+ * @param hostname Host name to resolve.
155
+ */
156
+ function resolve6(hostname: string): Promise<string[]>;
157
+ function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
158
+ function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
159
+ /**
160
+ * Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
161
+ * On success, the `Promise` is resolved with an array containing various types of
162
+ * records. Each object has a property `type` that indicates the type of the
163
+ * current record. And depending on the `type`, additional properties will be
164
+ * present on the object:
165
+ *
166
+ * <omitted>
167
+ *
168
+ * Here is an example of the result object:
169
+ *
170
+ * ```js
171
+ * [ { type: 'A', address: '127.0.0.1', ttl: 299 },
172
+ * { type: 'CNAME', value: 'example.com' },
173
+ * { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
174
+ * { type: 'NS', value: 'ns1.example.com' },
175
+ * { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
176
+ * { type: 'SOA',
177
+ * nsname: 'ns1.example.com',
178
+ * hostmaster: 'admin.example.com',
179
+ * serial: 156696742,
180
+ * refresh: 900,
181
+ * retry: 900,
182
+ * expire: 1800,
183
+ * minttl: 60 } ]
184
+ * ```
185
+ * @since v10.6.0
186
+ */
187
+ function resolveAny(hostname: string): Promise<AnyRecord[]>;
188
+ /**
189
+ * Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
190
+ * the `Promise` is resolved with an array of objects containing available
191
+ * certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:[email protected]'},{critical: 128, issue: 'pki.example.com'}]`).
192
+ * @since v15.0.0, v14.17.0
193
+ */
194
+ function resolveCaa(hostname: string): Promise<CaaRecord[]>;
195
+ /**
196
+ * Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
197
+ * the `Promise` is resolved with an array of canonical name records available for
198
+ * the `hostname` (e.g. `['bar.example.com']`).
199
+ * @since v10.6.0
200
+ */
201
+ function resolveCname(hostname: string): Promise<string[]>;
202
+ /**
203
+ * Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
204
+ * containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
205
+ * @since v10.6.0
206
+ */
207
+ function resolveMx(hostname: string): Promise<MxRecord[]>;
208
+ /**
209
+ * Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
210
+ * of objects with the following properties:
211
+ *
212
+ * * `flags`
213
+ * * `service`
214
+ * * `regexp`
215
+ * * `replacement`
216
+ * * `order`
217
+ * * `preference`
218
+ *
219
+ * ```js
220
+ * {
221
+ * flags: 's',
222
+ * service: 'SIP+D2U',
223
+ * regexp: '',
224
+ * replacement: '_sip._udp.example.com',
225
+ * order: 30,
226
+ * preference: 100
227
+ * }
228
+ * ```
229
+ * @since v10.6.0
230
+ */
231
+ function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
232
+ /**
233
+ * Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
234
+ * records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
235
+ * @since v10.6.0
236
+ */
237
+ function resolveNs(hostname: string): Promise<string[]>;
238
+ /**
239
+ * Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
240
+ * containing the reply records.
241
+ * @since v10.6.0
242
+ */
243
+ function resolvePtr(hostname: string): Promise<string[]>;
244
+ /**
245
+ * Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
246
+ * the `hostname`. On success, the `Promise` is resolved with an object with the
247
+ * following properties:
248
+ *
249
+ * * `nsname`
250
+ * * `hostmaster`
251
+ * * `serial`
252
+ * * `refresh`
253
+ * * `retry`
254
+ * * `expire`
255
+ * * `minttl`
256
+ *
257
+ * ```js
258
+ * {
259
+ * nsname: 'ns.example.com',
260
+ * hostmaster: 'root.example.com',
261
+ * serial: 2013101809,
262
+ * refresh: 10000,
263
+ * retry: 2400,
264
+ * expire: 604800,
265
+ * minttl: 3600
266
+ * }
267
+ * ```
268
+ * @since v10.6.0
269
+ */
270
+ function resolveSoa(hostname: string): Promise<SoaRecord>;
271
+ /**
272
+ * Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
273
+ * the following properties:
274
+ *
275
+ * * `priority`
276
+ * * `weight`
277
+ * * `port`
278
+ * * `name`
279
+ *
280
+ * ```js
281
+ * {
282
+ * priority: 10,
283
+ * weight: 5,
284
+ * port: 21223,
285
+ * name: 'service.example.com'
286
+ * }
287
+ * ```
288
+ * @since v10.6.0
289
+ */
290
+ function resolveSrv(hostname: string): Promise<SrvRecord[]>;
291
+ /**
292
+ * Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
293
+ * of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
294
+ * one record. Depending on the use case, these could be either joined together or
295
+ * treated separately.
296
+ * @since v10.6.0
297
+ */
298
+ function resolveTxt(hostname: string): Promise<string[][]>;
299
+ /**
300
+ * Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
301
+ * array of host names.
302
+ *
303
+ * On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
304
+ * @since v10.6.0
305
+ */
306
+ function reverse(ip: string): Promise<string[]>;
307
+ /**
308
+ * Sets the IP address and port of servers to be used when performing DNS
309
+ * resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
310
+ * addresses. If the port is the IANA default DNS port (53) it can be omitted.
311
+ *
312
+ * ```js
313
+ * dnsPromises.setServers([
314
+ * '4.4.4.4',
315
+ * '[2001:4860:4860::8888]',
316
+ * '4.4.4.4:1053',
317
+ * '[2001:4860:4860::8888]:1053',
318
+ * ]);
319
+ * ```
320
+ *
321
+ * An error will be thrown if an invalid address is provided.
322
+ *
323
+ * The `dnsPromises.setServers()` method must not be called while a DNS query is in
324
+ * progress.
325
+ *
326
+ * This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
327
+ * That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
328
+ * subsequent servers provided. Fallback DNS servers will only be used if the
329
+ * earlier ones time out or result in some other error.
330
+ * @since v10.6.0
331
+ * @param servers array of `RFC 5952` formatted addresses
332
+ */
333
+ function setServers(servers: ReadonlyArray<string>): void;
334
+ /**
335
+ * Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
336
+ *
337
+ * * `ipv4first`: sets default `verbatim` `false`.
338
+ * * `verbatim`: sets default `verbatim` `true`.
339
+ *
340
+ * The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have
341
+ * higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the
342
+ * default dns orders in workers.
343
+ * @since v16.4.0, v14.18.0
344
+ * @param order must be `'ipv4first'` or `'verbatim'`.
345
+ */
346
+ function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
347
+ class Resolver {
348
+ constructor(options?: ResolverOptions);
349
+ cancel(): void;
350
+ getServers: typeof getServers;
351
+ resolve: typeof resolve;
352
+ resolve4: typeof resolve4;
353
+ resolve6: typeof resolve6;
354
+ resolveAny: typeof resolveAny;
355
+ resolveCname: typeof resolveCname;
356
+ resolveMx: typeof resolveMx;
357
+ resolveNaptr: typeof resolveNaptr;
358
+ resolveNs: typeof resolveNs;
359
+ resolvePtr: typeof resolvePtr;
360
+ resolveSoa: typeof resolveSoa;
361
+ resolveSrv: typeof resolveSrv;
362
+ resolveTxt: typeof resolveTxt;
363
+ reverse: typeof reverse;
364
+ setLocalAddress(ipv4?: string, ipv6?: string): void;
365
+ setServers: typeof setServers;
366
+ }
367
+ }
368
+ declare module 'node:dns/promises' {
369
+ export * from 'dns/promises';
370
+ }
node_modules/@types/node/dom-events.d.ts ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export {}; // Don't export anything!
2
+
3
+ //// DOM-like Events
4
+ // NB: The Event / EventTarget / EventListener implementations below were copied
5
+ // from lib.dom.d.ts, then edited to reflect Node's documentation at
6
+ // https://nodejs.org/api/events.html#class-eventtarget.
7
+ // Please read that link to understand important implementation differences.
8
+
9
+ // This conditional type will be the existing global Event in a browser, or
10
+ // the copy below in a Node environment.
11
+ type __Event = typeof globalThis extends { onmessage: any, Event: any }
12
+ ? {}
13
+ : {
14
+ /** This is not used in Node.js and is provided purely for completeness. */
15
+ readonly bubbles: boolean;
16
+ /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
17
+ cancelBubble: () => void;
18
+ /** True if the event was created with the cancelable option */
19
+ readonly cancelable: boolean;
20
+ /** This is not used in Node.js and is provided purely for completeness. */
21
+ readonly composed: boolean;
22
+ /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
23
+ composedPath(): [EventTarget?]
24
+ /** Alias for event.target. */
25
+ readonly currentTarget: EventTarget | null;
26
+ /** Is true if cancelable is true and event.preventDefault() has been called. */
27
+ readonly defaultPrevented: boolean;
28
+ /** This is not used in Node.js and is provided purely for completeness. */
29
+ readonly eventPhase: 0 | 2;
30
+ /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
31
+ readonly isTrusted: boolean;
32
+ /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
33
+ preventDefault(): void;
34
+ /** This is not used in Node.js and is provided purely for completeness. */
35
+ returnValue: boolean;
36
+ /** Alias for event.target. */
37
+ readonly srcElement: EventTarget | null;
38
+ /** Stops the invocation of event listeners after the current one completes. */
39
+ stopImmediatePropagation(): void;
40
+ /** This is not used in Node.js and is provided purely for completeness. */
41
+ stopPropagation(): void;
42
+ /** The `EventTarget` dispatching the event */
43
+ readonly target: EventTarget | null;
44
+ /** The millisecond timestamp when the Event object was created. */
45
+ readonly timeStamp: number;
46
+ /** Returns the type of event, e.g. "click", "hashchange", or "submit". */
47
+ readonly type: string;
48
+ };
49
+
50
+ // See comment above explaining conditional type
51
+ type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any }
52
+ ? {}
53
+ : {
54
+ /**
55
+ * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
56
+ *
57
+ * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
58
+ *
59
+ * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
60
+ * Specifically, the `capture` option is used as part of the key when registering a `listener`.
61
+ * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
62
+ */
63
+ addEventListener(
64
+ type: string,
65
+ listener: EventListener | EventListenerObject,
66
+ options?: AddEventListenerOptions | boolean,
67
+ ): void;
68
+ /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
69
+ dispatchEvent(event: Event): boolean;
70
+ /** Removes the event listener in target's event listener list with the same type, callback, and options. */
71
+ removeEventListener(
72
+ type: string,
73
+ listener: EventListener | EventListenerObject,
74
+ options?: EventListenerOptions | boolean,
75
+ ): void;
76
+ };
77
+
78
+ interface EventInit {
79
+ bubbles?: boolean;
80
+ cancelable?: boolean;
81
+ composed?: boolean;
82
+ }
83
+
84
+ interface EventListenerOptions {
85
+ /** Not directly used by Node.js. Added for API completeness. Default: `false`. */
86
+ capture?: boolean;
87
+ }
88
+
89
+ interface AddEventListenerOptions extends EventListenerOptions {
90
+ /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
91
+ once?: boolean;
92
+ /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
93
+ passive?: boolean;
94
+ }
95
+
96
+ interface EventListener {
97
+ (evt: Event): void;
98
+ }
99
+
100
+ interface EventListenerObject {
101
+ handleEvent(object: Event): void;
102
+ }
103
+
104
+ import {} from 'events'; // Make this an ambient declaration
105
+ declare global {
106
+ /** An event which takes place in the DOM. */
107
+ interface Event extends __Event {}
108
+ var Event: typeof globalThis extends { onmessage: any, Event: infer T }
109
+ ? T
110
+ : {
111
+ prototype: __Event;
112
+ new (type: string, eventInitDict?: EventInit): __Event;
113
+ };
114
+
115
+ /**
116
+ * EventTarget is a DOM interface implemented by objects that can
117
+ * receive events and may have listeners for them.
118
+ */
119
+ interface EventTarget extends __EventTarget {}
120
+ var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T }
121
+ ? T
122
+ : {
123
+ prototype: __EventTarget;
124
+ new (): __EventTarget;
125
+ };
126
+ }
node_modules/@types/node/domain.d.ts ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * **This module is pending deprecation.** Once a replacement API has been
3
+ * finalized, this module will be fully deprecated. Most developers should
4
+ * **not** have cause to use this module. Users who absolutely must have
5
+ * the functionality that domains provide may rely on it for the time being
6
+ * but should expect to have to migrate to a different solution
7
+ * in the future.
8
+ *
9
+ * Domains provide a way to handle multiple different IO operations as a
10
+ * single group. If any of the event emitters or callbacks registered to a
11
+ * domain emit an `'error'` event, or throw an error, then the domain object
12
+ * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
13
+ * exit immediately with an error code.
14
+ * @deprecated Since v1.4.2 - Deprecated
15
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js)
16
+ */
17
+ declare module 'domain' {
18
+ import EventEmitter = require('node:events');
19
+ /**
20
+ * The `Domain` class encapsulates the functionality of routing errors and
21
+ * uncaught exceptions to the active `Domain` object.
22
+ *
23
+ * To handle the errors that it catches, listen to its `'error'` event.
24
+ */
25
+ class Domain extends EventEmitter {
26
+ /**
27
+ * An array of timers and event emitters that have been explicitly added
28
+ * to the domain.
29
+ */
30
+ members: Array<EventEmitter | NodeJS.Timer>;
31
+ /**
32
+ * The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly
33
+ * pushes the domain onto the domain
34
+ * stack managed by the domain module (see {@link exit} for details on the
35
+ * domain stack). The call to `enter()` delimits the beginning of a chain of
36
+ * asynchronous calls and I/O operations bound to a domain.
37
+ *
38
+ * Calling `enter()` changes only the active domain, and does not alter the domain
39
+ * itself. `enter()` and `exit()` can be called an arbitrary number of times on a
40
+ * single domain.
41
+ */
42
+ enter(): void;
43
+ /**
44
+ * The `exit()` method exits the current domain, popping it off the domain stack.
45
+ * Any time execution is going to switch to the context of a different chain of
46
+ * asynchronous calls, it's important to ensure that the current domain is exited.
47
+ * The call to `exit()` delimits either the end of or an interruption to the chain
48
+ * of asynchronous calls and I/O operations bound to a domain.
49
+ *
50
+ * If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain.
51
+ *
52
+ * Calling `exit()` changes only the active domain, and does not alter the domain
53
+ * itself. `enter()` and `exit()` can be called an arbitrary number of times on a
54
+ * single domain.
55
+ */
56
+ exit(): void;
57
+ /**
58
+ * Run the supplied function in the context of the domain, implicitly
59
+ * binding all event emitters, timers, and lowlevel requests that are
60
+ * created in that context. Optionally, arguments can be passed to
61
+ * the function.
62
+ *
63
+ * This is the most basic way to use a domain.
64
+ *
65
+ * ```js
66
+ * const domain = require('domain');
67
+ * const fs = require('fs');
68
+ * const d = domain.create();
69
+ * d.on('error', (er) => {
70
+ * console.error('Caught error!', er);
71
+ * });
72
+ * d.run(() => {
73
+ * process.nextTick(() => {
74
+ * setTimeout(() => { // Simulating some various async stuff
75
+ * fs.open('non-existent file', 'r', (er, fd) => {
76
+ * if (er) throw er;
77
+ * // proceed...
78
+ * });
79
+ * }, 100);
80
+ * });
81
+ * });
82
+ * ```
83
+ *
84
+ * In this example, the `d.on('error')` handler will be triggered, rather
85
+ * than crashing the program.
86
+ */
87
+ run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
88
+ /**
89
+ * Explicitly adds an emitter to the domain. If any event handlers called by
90
+ * the emitter throw an error, or if the emitter emits an `'error'` event, it
91
+ * will be routed to the domain's `'error'` event, just like with implicit
92
+ * binding.
93
+ *
94
+ * This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
95
+ * the domain `'error'` handler.
96
+ *
97
+ * If the Timer or `EventEmitter` was already bound to a domain, it is removed
98
+ * from that one, and bound to this one instead.
99
+ * @param emitter emitter or timer to be added to the domain
100
+ */
101
+ add(emitter: EventEmitter | NodeJS.Timer): void;
102
+ /**
103
+ * The opposite of {@link add}. Removes domain handling from the
104
+ * specified emitter.
105
+ * @param emitter emitter or timer to be removed from the domain
106
+ */
107
+ remove(emitter: EventEmitter | NodeJS.Timer): void;
108
+ /**
109
+ * The returned function will be a wrapper around the supplied callback
110
+ * function. When the returned function is called, any errors that are
111
+ * thrown will be routed to the domain's `'error'` event.
112
+ *
113
+ * ```js
114
+ * const d = domain.create();
115
+ *
116
+ * function readSomeFile(filename, cb) {
117
+ * fs.readFile(filename, 'utf8', d.bind((er, data) => {
118
+ * // If this throws, it will also be passed to the domain.
119
+ * return cb(er, data ? JSON.parse(data) : null);
120
+ * }));
121
+ * }
122
+ *
123
+ * d.on('error', (er) => {
124
+ * // An error occurred somewhere. If we throw it now, it will crash the program
125
+ * // with the normal line number and stack message.
126
+ * });
127
+ * ```
128
+ * @param callback The callback function
129
+ * @return The bound function
130
+ */
131
+ bind<T extends Function>(callback: T): T;
132
+ /**
133
+ * This method is almost identical to {@link bind}. However, in
134
+ * addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
135
+ *
136
+ * In this way, the common `if (err) return callback(err);` pattern can be replaced
137
+ * with a single error handler in a single place.
138
+ *
139
+ * ```js
140
+ * const d = domain.create();
141
+ *
142
+ * function readSomeFile(filename, cb) {
143
+ * fs.readFile(filename, 'utf8', d.intercept((data) => {
144
+ * // Note, the first argument is never passed to the
145
+ * // callback since it is assumed to be the 'Error' argument
146
+ * // and thus intercepted by the domain.
147
+ *
148
+ * // If this throws, it will also be passed to the domain
149
+ * // so the error-handling logic can be moved to the 'error'
150
+ * // event on the domain instead of being repeated throughout
151
+ * // the program.
152
+ * return cb(null, JSON.parse(data));
153
+ * }));
154
+ * }
155
+ *
156
+ * d.on('error', (er) => {
157
+ * // An error occurred somewhere. If we throw it now, it will crash the program
158
+ * // with the normal line number and stack message.
159
+ * });
160
+ * ```
161
+ * @param callback The callback function
162
+ * @return The intercepted function
163
+ */
164
+ intercept<T extends Function>(callback: T): T;
165
+ }
166
+ function create(): Domain;
167
+ }
168
+ declare module 'node:domain' {
169
+ export * from 'domain';
170
+ }
node_modules/@types/node/events.d.ts ADDED
@@ -0,0 +1,678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Much of the Node.js core API is built around an idiomatic asynchronous
3
+ * event-driven architecture in which certain kinds of objects (called "emitters")
4
+ * emit named events that cause `Function` objects ("listeners") to be called.
5
+ *
6
+ * For instance: a `net.Server` object emits an event each time a peer
7
+ * connects to it; a `fs.ReadStream` emits an event when the file is opened;
8
+ * a `stream` emits an event whenever data is available to be read.
9
+ *
10
+ * All objects that emit events are instances of the `EventEmitter` class. These
11
+ * objects expose an `eventEmitter.on()` function that allows one or more
12
+ * functions to be attached to named events emitted by the object. Typically,
13
+ * event names are camel-cased strings but any valid JavaScript property key
14
+ * can be used.
15
+ *
16
+ * When the `EventEmitter` object emits an event, all of the functions attached
17
+ * to that specific event are called _synchronously_. Any values returned by the
18
+ * called listeners are _ignored_ and discarded.
19
+ *
20
+ * The following example shows a simple `EventEmitter` instance with a single
21
+ * listener. The `eventEmitter.on()` method is used to register listeners, while
22
+ * the `eventEmitter.emit()` method is used to trigger the event.
23
+ *
24
+ * ```js
25
+ * const EventEmitter = require('events');
26
+ *
27
+ * class MyEmitter extends EventEmitter {}
28
+ *
29
+ * const myEmitter = new MyEmitter();
30
+ * myEmitter.on('event', () => {
31
+ * console.log('an event occurred!');
32
+ * });
33
+ * myEmitter.emit('event');
34
+ * ```
35
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
36
+ */
37
+ declare module 'events' {
38
+ // NOTE: This class is in the docs but is **not actually exported** by Node.
39
+ // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
40
+ // actually starts exporting the class, uncomment below.
41
+
42
+ // import { EventListener, EventListenerObject } from '__dom-events';
43
+ // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
44
+ // interface NodeEventTarget extends EventTarget {
45
+ // /**
46
+ // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
47
+ // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
48
+ // */
49
+ // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
50
+ // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
51
+ // eventNames(): string[];
52
+ // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
53
+ // listenerCount(type: string): number;
54
+ // /** Node.js-specific alias for `eventTarget.removeListener()`. */
55
+ // off(type: string, listener: EventListener | EventListenerObject): this;
56
+ // /** Node.js-specific alias for `eventTarget.addListener()`. */
57
+ // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
58
+ // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
59
+ // once(type: string, listener: EventListener | EventListenerObject): this;
60
+ // /**
61
+ // * Node.js-specific extension to the `EventTarget` class.
62
+ // * If `type` is specified, removes all registered listeners for `type`,
63
+ // * otherwise removes all registered listeners.
64
+ // */
65
+ // removeAllListeners(type: string): this;
66
+ // /**
67
+ // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
68
+ // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
69
+ // */
70
+ // removeListener(type: string, listener: EventListener | EventListenerObject): this;
71
+ // }
72
+
73
+ interface EventEmitterOptions {
74
+ /**
75
+ * Enables automatic capturing of promise rejection.
76
+ */
77
+ captureRejections?: boolean | undefined;
78
+ }
79
+ // Any EventTarget with a Node-style `once` function
80
+ interface _NodeEventTarget {
81
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
82
+ }
83
+ // Any EventTarget with a DOM-style `addEventListener`
84
+ interface _DOMEventTarget {
85
+ addEventListener(
86
+ eventName: string,
87
+ listener: (...args: any[]) => void,
88
+ opts?: {
89
+ once: boolean;
90
+ }
91
+ ): any;
92
+ }
93
+ interface StaticEventEmitterOptions {
94
+ signal?: AbortSignal | undefined;
95
+ }
96
+ interface EventEmitter extends NodeJS.EventEmitter {}
97
+ /**
98
+ * The `EventEmitter` class is defined and exposed by the `events` module:
99
+ *
100
+ * ```js
101
+ * const EventEmitter = require('events');
102
+ * ```
103
+ *
104
+ * All `EventEmitter`s emit the event `'newListener'` when new listeners are
105
+ * added and `'removeListener'` when existing listeners are removed.
106
+ *
107
+ * It supports the following option:
108
+ * @since v0.1.26
109
+ */
110
+ class EventEmitter {
111
+ constructor(options?: EventEmitterOptions);
112
+ /**
113
+ * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
114
+ * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
115
+ * The `Promise` will resolve with an array of all the arguments emitted to the
116
+ * given event.
117
+ *
118
+ * This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
119
+ * semantics and does not listen to the `'error'` event.
120
+ *
121
+ * ```js
122
+ * const { once, EventEmitter } = require('events');
123
+ *
124
+ * async function run() {
125
+ * const ee = new EventEmitter();
126
+ *
127
+ * process.nextTick(() => {
128
+ * ee.emit('myevent', 42);
129
+ * });
130
+ *
131
+ * const [value] = await once(ee, 'myevent');
132
+ * console.log(value);
133
+ *
134
+ * const err = new Error('kaboom');
135
+ * process.nextTick(() => {
136
+ * ee.emit('error', err);
137
+ * });
138
+ *
139
+ * try {
140
+ * await once(ee, 'myevent');
141
+ * } catch (err) {
142
+ * console.log('error happened', err);
143
+ * }
144
+ * }
145
+ *
146
+ * run();
147
+ * ```
148
+ *
149
+ * The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
150
+ * '`error'` event itself, then it is treated as any other kind of event without
151
+ * special handling:
152
+ *
153
+ * ```js
154
+ * const { EventEmitter, once } = require('events');
155
+ *
156
+ * const ee = new EventEmitter();
157
+ *
158
+ * once(ee, 'error')
159
+ * .then(([err]) => console.log('ok', err.message))
160
+ * .catch((err) => console.log('error', err.message));
161
+ *
162
+ * ee.emit('error', new Error('boom'));
163
+ *
164
+ * // Prints: ok boom
165
+ * ```
166
+ *
167
+ * An `AbortSignal` can be used to cancel waiting for the event:
168
+ *
169
+ * ```js
170
+ * const { EventEmitter, once } = require('events');
171
+ *
172
+ * const ee = new EventEmitter();
173
+ * const ac = new AbortController();
174
+ *
175
+ * async function foo(emitter, event, signal) {
176
+ * try {
177
+ * await once(emitter, event, { signal });
178
+ * console.log('event emitted!');
179
+ * } catch (error) {
180
+ * if (error.name === 'AbortError') {
181
+ * console.error('Waiting for the event was canceled!');
182
+ * } else {
183
+ * console.error('There was an error', error.message);
184
+ * }
185
+ * }
186
+ * }
187
+ *
188
+ * foo(ee, 'foo', ac.signal);
189
+ * ac.abort(); // Abort waiting for the event
190
+ * ee.emit('foo'); // Prints: Waiting for the event was canceled!
191
+ * ```
192
+ * @since v11.13.0, v10.16.0
193
+ */
194
+ static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
195
+ static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
196
+ /**
197
+ * ```js
198
+ * const { on, EventEmitter } = require('events');
199
+ *
200
+ * (async () => {
201
+ * const ee = new EventEmitter();
202
+ *
203
+ * // Emit later on
204
+ * process.nextTick(() => {
205
+ * ee.emit('foo', 'bar');
206
+ * ee.emit('foo', 42);
207
+ * });
208
+ *
209
+ * for await (const event of on(ee, 'foo')) {
210
+ * // The execution of this inner block is synchronous and it
211
+ * // processes one event at a time (even with await). Do not use
212
+ * // if concurrent execution is required.
213
+ * console.log(event); // prints ['bar'] [42]
214
+ * }
215
+ * // Unreachable here
216
+ * })();
217
+ * ```
218
+ *
219
+ * Returns an `AsyncIterator` that iterates `eventName` events. It will throw
220
+ * if the `EventEmitter` emits `'error'`. It removes all listeners when
221
+ * exiting the loop. The `value` returned by each iteration is an array
222
+ * composed of the emitted event arguments.
223
+ *
224
+ * An `AbortSignal` can be used to cancel waiting on events:
225
+ *
226
+ * ```js
227
+ * const { on, EventEmitter } = require('events');
228
+ * const ac = new AbortController();
229
+ *
230
+ * (async () => {
231
+ * const ee = new EventEmitter();
232
+ *
233
+ * // Emit later on
234
+ * process.nextTick(() => {
235
+ * ee.emit('foo', 'bar');
236
+ * ee.emit('foo', 42);
237
+ * });
238
+ *
239
+ * for await (const event of on(ee, 'foo', { signal: ac.signal })) {
240
+ * // The execution of this inner block is synchronous and it
241
+ * // processes one event at a time (even with await). Do not use
242
+ * // if concurrent execution is required.
243
+ * console.log(event); // prints ['bar'] [42]
244
+ * }
245
+ * // Unreachable here
246
+ * })();
247
+ *
248
+ * process.nextTick(() => ac.abort());
249
+ * ```
250
+ * @since v13.6.0, v12.16.0
251
+ * @param eventName The name of the event being listened for
252
+ * @return that iterates `eventName` events emitted by the `emitter`
253
+ */
254
+ static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
255
+ /**
256
+ * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
257
+ *
258
+ * ```js
259
+ * const { EventEmitter, listenerCount } = require('events');
260
+ * const myEmitter = new EventEmitter();
261
+ * myEmitter.on('event', () => {});
262
+ * myEmitter.on('event', () => {});
263
+ * console.log(listenerCount(myEmitter, 'event'));
264
+ * // Prints: 2
265
+ * ```
266
+ * @since v0.9.12
267
+ * @deprecated Since v3.2.0 - Use `listenerCount` instead.
268
+ * @param emitter The emitter to query
269
+ * @param eventName The event name
270
+ */
271
+ static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
272
+ /**
273
+ * Returns a copy of the array of listeners for the event named `eventName`.
274
+ *
275
+ * For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
276
+ * the emitter.
277
+ *
278
+ * For `EventTarget`s this is the only way to get the event listeners for the
279
+ * event target. This is useful for debugging and diagnostic purposes.
280
+ *
281
+ * ```js
282
+ * const { getEventListeners, EventEmitter } = require('events');
283
+ *
284
+ * {
285
+ * const ee = new EventEmitter();
286
+ * const listener = () => console.log('Events are fun');
287
+ * ee.on('foo', listener);
288
+ * getEventListeners(ee, 'foo'); // [listener]
289
+ * }
290
+ * {
291
+ * const et = new EventTarget();
292
+ * const listener = () => console.log('Events are fun');
293
+ * et.addEventListener('foo', listener);
294
+ * getEventListeners(et, 'foo'); // [listener]
295
+ * }
296
+ * ```
297
+ * @since v15.2.0, v14.17.0
298
+ */
299
+ static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
300
+ /**
301
+ * ```js
302
+ * const {
303
+ * setMaxListeners,
304
+ * EventEmitter
305
+ * } = require('events');
306
+ *
307
+ * const target = new EventTarget();
308
+ * const emitter = new EventEmitter();
309
+ *
310
+ * setMaxListeners(5, target, emitter);
311
+ * ```
312
+ * @since v15.4.0
313
+ * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
314
+ * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
315
+ * objects.
316
+ */
317
+ static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
318
+ /**
319
+ * This symbol shall be used to install a listener for only monitoring `'error'`
320
+ * events. Listeners installed using this symbol are called before the regular
321
+ * `'error'` listeners are called.
322
+ *
323
+ * Installing a listener using this symbol does not change the behavior once an
324
+ * `'error'` event is emitted, therefore the process will still crash if no
325
+ * regular `'error'` listener is installed.
326
+ */
327
+ static readonly errorMonitor: unique symbol;
328
+ static readonly captureRejectionSymbol: unique symbol;
329
+ /**
330
+ * Sets or gets the default captureRejection value for all emitters.
331
+ */
332
+ // TODO: These should be described using static getter/setter pairs:
333
+ static captureRejections: boolean;
334
+ static defaultMaxListeners: number;
335
+ }
336
+ import internal = require('node:events');
337
+ namespace EventEmitter {
338
+ // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
339
+ export { internal as EventEmitter };
340
+ export interface Abortable {
341
+ /**
342
+ * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
343
+ */
344
+ signal?: AbortSignal | undefined;
345
+ }
346
+ }
347
+ global {
348
+ namespace NodeJS {
349
+ interface EventEmitter {
350
+ /**
351
+ * Alias for `emitter.on(eventName, listener)`.
352
+ * @since v0.1.26
353
+ */
354
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
355
+ /**
356
+ * Adds the `listener` function to the end of the listeners array for the
357
+ * event named `eventName`. No checks are made to see if the `listener` has
358
+ * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
359
+ * times.
360
+ *
361
+ * ```js
362
+ * server.on('connection', (stream) => {
363
+ * console.log('someone connected!');
364
+ * });
365
+ * ```
366
+ *
367
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
368
+ *
369
+ * By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
370
+ * event listener to the beginning of the listeners array.
371
+ *
372
+ * ```js
373
+ * const myEE = new EventEmitter();
374
+ * myEE.on('foo', () => console.log('a'));
375
+ * myEE.prependListener('foo', () => console.log('b'));
376
+ * myEE.emit('foo');
377
+ * // Prints:
378
+ * // b
379
+ * // a
380
+ * ```
381
+ * @since v0.1.101
382
+ * @param eventName The name of the event.
383
+ * @param listener The callback function
384
+ */
385
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
386
+ /**
387
+ * Adds a **one-time**`listener` function for the event named `eventName`. The
388
+ * next time `eventName` is triggered, this listener is removed and then invoked.
389
+ *
390
+ * ```js
391
+ * server.once('connection', (stream) => {
392
+ * console.log('Ah, we have our first user!');
393
+ * });
394
+ * ```
395
+ *
396
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
397
+ *
398
+ * By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
399
+ * event listener to the beginning of the listeners array.
400
+ *
401
+ * ```js
402
+ * const myEE = new EventEmitter();
403
+ * myEE.once('foo', () => console.log('a'));
404
+ * myEE.prependOnceListener('foo', () => console.log('b'));
405
+ * myEE.emit('foo');
406
+ * // Prints:
407
+ * // b
408
+ * // a
409
+ * ```
410
+ * @since v0.3.0
411
+ * @param eventName The name of the event.
412
+ * @param listener The callback function
413
+ */
414
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
415
+ /**
416
+ * Removes the specified `listener` from the listener array for the event named`eventName`.
417
+ *
418
+ * ```js
419
+ * const callback = (stream) => {
420
+ * console.log('someone connected!');
421
+ * };
422
+ * server.on('connection', callback);
423
+ * // ...
424
+ * server.removeListener('connection', callback);
425
+ * ```
426
+ *
427
+ * `removeListener()` will remove, at most, one instance of a listener from the
428
+ * listener array. If any single listener has been added multiple times to the
429
+ * listener array for the specified `eventName`, then `removeListener()` must be
430
+ * called multiple times to remove each instance.
431
+ *
432
+ * Once an event is emitted, all listeners attached to it at the
433
+ * time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
434
+ * will not remove them from`emit()` in progress. Subsequent events behave as expected.
435
+ *
436
+ * ```js
437
+ * const myEmitter = new MyEmitter();
438
+ *
439
+ * const callbackA = () => {
440
+ * console.log('A');
441
+ * myEmitter.removeListener('event', callbackB);
442
+ * };
443
+ *
444
+ * const callbackB = () => {
445
+ * console.log('B');
446
+ * };
447
+ *
448
+ * myEmitter.on('event', callbackA);
449
+ *
450
+ * myEmitter.on('event', callbackB);
451
+ *
452
+ * // callbackA removes listener callbackB but it will still be called.
453
+ * // Internal listener array at time of emit [callbackA, callbackB]
454
+ * myEmitter.emit('event');
455
+ * // Prints:
456
+ * // A
457
+ * // B
458
+ *
459
+ * // callbackB is now removed.
460
+ * // Internal listener array [callbackA]
461
+ * myEmitter.emit('event');
462
+ * // Prints:
463
+ * // A
464
+ * ```
465
+ *
466
+ * Because listeners are managed using an internal array, calling this will
467
+ * change the position indices of any listener registered _after_ the listener
468
+ * being removed. This will not impact the order in which listeners are called,
469
+ * but it means that any copies of the listener array as returned by
470
+ * the `emitter.listeners()` method will need to be recreated.
471
+ *
472
+ * When a single function has been added as a handler multiple times for a single
473
+ * event (as in the example below), `removeListener()` will remove the most
474
+ * recently added instance. In the example the `once('ping')`listener is removed:
475
+ *
476
+ * ```js
477
+ * const ee = new EventEmitter();
478
+ *
479
+ * function pong() {
480
+ * console.log('pong');
481
+ * }
482
+ *
483
+ * ee.on('ping', pong);
484
+ * ee.once('ping', pong);
485
+ * ee.removeListener('ping', pong);
486
+ *
487
+ * ee.emit('ping');
488
+ * ee.emit('ping');
489
+ * ```
490
+ *
491
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
492
+ * @since v0.1.26
493
+ */
494
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
495
+ /**
496
+ * Alias for `emitter.removeListener()`.
497
+ * @since v10.0.0
498
+ */
499
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
500
+ /**
501
+ * Removes all listeners, or those of the specified `eventName`.
502
+ *
503
+ * It is bad practice to remove listeners added elsewhere in the code,
504
+ * particularly when the `EventEmitter` instance was created by some other
505
+ * component or module (e.g. sockets or file streams).
506
+ *
507
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
508
+ * @since v0.1.26
509
+ */
510
+ removeAllListeners(event?: string | symbol): this;
511
+ /**
512
+ * By default `EventEmitter`s will print a warning if more than `10` listeners are
513
+ * added for a particular event. This is a useful default that helps finding
514
+ * memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
515
+ * modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
516
+ *
517
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
518
+ * @since v0.3.5
519
+ */
520
+ setMaxListeners(n: number): this;
521
+ /**
522
+ * Returns the current max listener value for the `EventEmitter` which is either
523
+ * set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
524
+ * @since v1.0.0
525
+ */
526
+ getMaxListeners(): number;
527
+ /**
528
+ * Returns a copy of the array of listeners for the event named `eventName`.
529
+ *
530
+ * ```js
531
+ * server.on('connection', (stream) => {
532
+ * console.log('someone connected!');
533
+ * });
534
+ * console.log(util.inspect(server.listeners('connection')));
535
+ * // Prints: [ [Function] ]
536
+ * ```
537
+ * @since v0.1.26
538
+ */
539
+ listeners(eventName: string | symbol): Function[];
540
+ /**
541
+ * Returns a copy of the array of listeners for the event named `eventName`,
542
+ * including any wrappers (such as those created by `.once()`).
543
+ *
544
+ * ```js
545
+ * const emitter = new EventEmitter();
546
+ * emitter.once('log', () => console.log('log once'));
547
+ *
548
+ * // Returns a new Array with a function `onceWrapper` which has a property
549
+ * // `listener` which contains the original listener bound above
550
+ * const listeners = emitter.rawListeners('log');
551
+ * const logFnWrapper = listeners[0];
552
+ *
553
+ * // Logs "log once" to the console and does not unbind the `once` event
554
+ * logFnWrapper.listener();
555
+ *
556
+ * // Logs "log once" to the console and removes the listener
557
+ * logFnWrapper();
558
+ *
559
+ * emitter.on('log', () => console.log('log persistently'));
560
+ * // Will return a new Array with a single function bound by `.on()` above
561
+ * const newListeners = emitter.rawListeners('log');
562
+ *
563
+ * // Logs "log persistently" twice
564
+ * newListeners[0]();
565
+ * emitter.emit('log');
566
+ * ```
567
+ * @since v9.4.0
568
+ */
569
+ rawListeners(eventName: string | symbol): Function[];
570
+ /**
571
+ * Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
572
+ * to each.
573
+ *
574
+ * Returns `true` if the event had listeners, `false` otherwise.
575
+ *
576
+ * ```js
577
+ * const EventEmitter = require('events');
578
+ * const myEmitter = new EventEmitter();
579
+ *
580
+ * // First listener
581
+ * myEmitter.on('event', function firstListener() {
582
+ * console.log('Helloooo! first listener');
583
+ * });
584
+ * // Second listener
585
+ * myEmitter.on('event', function secondListener(arg1, arg2) {
586
+ * console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
587
+ * });
588
+ * // Third listener
589
+ * myEmitter.on('event', function thirdListener(...args) {
590
+ * const parameters = args.join(', ');
591
+ * console.log(`event with parameters ${parameters} in third listener`);
592
+ * });
593
+ *
594
+ * console.log(myEmitter.listeners('event'));
595
+ *
596
+ * myEmitter.emit('event', 1, 2, 3, 4, 5);
597
+ *
598
+ * // Prints:
599
+ * // [
600
+ * // [Function: firstListener],
601
+ * // [Function: secondListener],
602
+ * // [Function: thirdListener]
603
+ * // ]
604
+ * // Helloooo! first listener
605
+ * // event with parameters 1, 2 in second listener
606
+ * // event with parameters 1, 2, 3, 4, 5 in third listener
607
+ * ```
608
+ * @since v0.1.26
609
+ */
610
+ emit(eventName: string | symbol, ...args: any[]): boolean;
611
+ /**
612
+ * Returns the number of listeners listening to the event named `eventName`.
613
+ * @since v3.2.0
614
+ * @param eventName The name of the event being listened for
615
+ */
616
+ listenerCount(eventName: string | symbol): number;
617
+ /**
618
+ * Adds the `listener` function to the _beginning_ of the listeners array for the
619
+ * event named `eventName`. No checks are made to see if the `listener` has
620
+ * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
621
+ * times.
622
+ *
623
+ * ```js
624
+ * server.prependListener('connection', (stream) => {
625
+ * console.log('someone connected!');
626
+ * });
627
+ * ```
628
+ *
629
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
630
+ * @since v6.0.0
631
+ * @param eventName The name of the event.
632
+ * @param listener The callback function
633
+ */
634
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
635
+ /**
636
+ * Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this
637
+ * listener is removed, and then invoked.
638
+ *
639
+ * ```js
640
+ * server.prependOnceListener('connection', (stream) => {
641
+ * console.log('Ah, we have our first user!');
642
+ * });
643
+ * ```
644
+ *
645
+ * Returns a reference to the `EventEmitter`, so that calls can be chained.
646
+ * @since v6.0.0
647
+ * @param eventName The name of the event.
648
+ * @param listener The callback function
649
+ */
650
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
651
+ /**
652
+ * Returns an array listing the events for which the emitter has registered
653
+ * listeners. The values in the array are strings or `Symbol`s.
654
+ *
655
+ * ```js
656
+ * const EventEmitter = require('events');
657
+ * const myEE = new EventEmitter();
658
+ * myEE.on('foo', () => {});
659
+ * myEE.on('bar', () => {});
660
+ *
661
+ * const sym = Symbol('symbol');
662
+ * myEE.on(sym, () => {});
663
+ *
664
+ * console.log(myEE.eventNames());
665
+ * // Prints: [ 'foo', 'bar', Symbol(symbol) ]
666
+ * ```
667
+ * @since v6.0.0
668
+ */
669
+ eventNames(): Array<string | symbol>;
670
+ }
671
+ }
672
+ }
673
+ export = EventEmitter;
674
+ }
675
+ declare module 'node:events' {
676
+ import events = require('events');
677
+ export = events;
678
+ }
node_modules/@types/node/fs.d.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@types/node/fs/promises.d.ts ADDED
@@ -0,0 +1,1138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `fs/promises` API provides asynchronous file system methods that return
3
+ * promises.
4
+ *
5
+ * The promise APIs use the underlying Node.js threadpool to perform file
6
+ * system operations off the event loop thread. These operations are not
7
+ * synchronized or threadsafe. Care must be taken when performing multiple
8
+ * concurrent modifications on the same file or data corruption may occur.
9
+ * @since v10.0.0
10
+ */
11
+ declare module 'fs/promises' {
12
+ import { Abortable } from 'node:events';
13
+ import { Stream } from 'node:stream';
14
+ import { ReadableStream } from 'node:stream/web';
15
+ import {
16
+ BigIntStats,
17
+ BufferEncodingOption,
18
+ constants as fsConstants,
19
+ CopyOptions,
20
+ Dir,
21
+ Dirent,
22
+ MakeDirectoryOptions,
23
+ Mode,
24
+ ObjectEncodingOptions,
25
+ OpenDirOptions,
26
+ OpenMode,
27
+ PathLike,
28
+ ReadStream,
29
+ ReadVResult,
30
+ RmDirOptions,
31
+ RmOptions,
32
+ StatOptions,
33
+ Stats,
34
+ TimeLike,
35
+ WatchEventType,
36
+ WatchOptions,
37
+ WriteStream,
38
+ WriteVResult,
39
+ } from 'node:fs';
40
+ import { Interface as ReadlineInterface } from 'node:readline';
41
+
42
+ interface FileChangeInfo<T extends string | Buffer> {
43
+ eventType: WatchEventType;
44
+ filename: T;
45
+ }
46
+ interface FlagAndOpenMode {
47
+ mode?: Mode | undefined;
48
+ flag?: OpenMode | undefined;
49
+ }
50
+ interface FileReadResult<T extends NodeJS.ArrayBufferView> {
51
+ bytesRead: number;
52
+ buffer: T;
53
+ }
54
+ interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
55
+ /**
56
+ * @default `Buffer.alloc(0xffff)`
57
+ */
58
+ buffer?: T;
59
+ /**
60
+ * @default 0
61
+ */
62
+ offset?: number | null;
63
+ /**
64
+ * @default `buffer.byteLength`
65
+ */
66
+ length?: number | null;
67
+ position?: number | null;
68
+ }
69
+ interface CreateReadStreamOptions {
70
+ encoding?: BufferEncoding | null | undefined;
71
+ autoClose?: boolean | undefined;
72
+ emitClose?: boolean | undefined;
73
+ start?: number | undefined;
74
+ end?: number | undefined;
75
+ highWaterMark?: number | undefined;
76
+ }
77
+ interface CreateWriteStreamOptions {
78
+ encoding?: BufferEncoding | null | undefined;
79
+ autoClose?: boolean | undefined;
80
+ emitClose?: boolean | undefined;
81
+ start?: number | undefined;
82
+ }
83
+ // TODO: Add `EventEmitter` close
84
+ interface FileHandle {
85
+ /**
86
+ * The numeric file descriptor managed by the {FileHandle} object.
87
+ * @since v10.0.0
88
+ */
89
+ readonly fd: number;
90
+ /**
91
+ * Alias of `filehandle.writeFile()`.
92
+ *
93
+ * When operating on file handles, the mode cannot be changed from what it was set
94
+ * to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`.
95
+ * @since v10.0.0
96
+ * @return Fulfills with `undefined` upon success.
97
+ */
98
+ appendFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
99
+ /**
100
+ * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
101
+ * @since v10.0.0
102
+ * @param uid The file's new owner's user id.
103
+ * @param gid The file's new group's group id.
104
+ * @return Fulfills with `undefined` upon success.
105
+ */
106
+ chown(uid: number, gid: number): Promise<void>;
107
+ /**
108
+ * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
109
+ * @since v10.0.0
110
+ * @param mode the file mode bit mask.
111
+ * @return Fulfills with `undefined` upon success.
112
+ */
113
+ chmod(mode: Mode): Promise<void>;
114
+ /**
115
+ * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
116
+ * returned by this method has a default `highWaterMark` of 64 kb.
117
+ *
118
+ * `options` can include `start` and `end` values to read a range of bytes from
119
+ * the file instead of the entire file. Both `start` and `end` are inclusive and
120
+ * start counting at 0, allowed values are in the
121
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is
122
+ * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from
123
+ * the current file position. The `encoding` can be any one of those accepted by `Buffer`.
124
+ *
125
+ * If the `FileHandle` points to a character device that only supports blocking
126
+ * reads (such as keyboard or sound card), read operations do not finish until data
127
+ * is available. This can prevent the process from exiting and the stream from
128
+ * closing naturally.
129
+ *
130
+ * By default, the stream will emit a `'close'` event after it has been
131
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
132
+ *
133
+ * ```js
134
+ * import { open } from 'fs/promises';
135
+ *
136
+ * const fd = await open('/dev/input/event0');
137
+ * // Create a stream from some character device.
138
+ * const stream = fd.createReadStream();
139
+ * setTimeout(() => {
140
+ * stream.close(); // This may not close the stream.
141
+ * // Artificially marking end-of-stream, as if the underlying resource had
142
+ * // indicated end-of-file by itself, allows the stream to close.
143
+ * // This does not cancel pending read operations, and if there is such an
144
+ * // operation, the process may still not be able to exit successfully
145
+ * // until it finishes.
146
+ * stream.push(null);
147
+ * stream.read(0);
148
+ * }, 100);
149
+ * ```
150
+ *
151
+ * If `autoClose` is false, then the file descriptor won't be closed, even if
152
+ * there's an error. It is the application's responsibility to close it and make
153
+ * sure there's no file descriptor leak. If `autoClose` is set to true (default
154
+ * behavior), on `'error'` or `'end'` the file descriptor will be closed
155
+ * automatically.
156
+ *
157
+ * An example to read the last 10 bytes of a file which is 100 bytes long:
158
+ *
159
+ * ```js
160
+ * import { open } from 'fs/promises';
161
+ *
162
+ * const fd = await open('sample.txt');
163
+ * fd.createReadStream({ start: 90, end: 99 });
164
+ * ```
165
+ * @since v16.11.0
166
+ */
167
+ createReadStream(options?: CreateReadStreamOptions): ReadStream;
168
+ /**
169
+ * `options` may also include a `start` option to allow writing data at some
170
+ * position past the beginning of the file, allowed values are in the
171
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
172
+ * replacing it may require the `flags` `open` option to be set to `r+` rather than
173
+ * the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
174
+ *
175
+ * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
176
+ * then the file descriptor won't be closed, even if there's an error.
177
+ * It is the application's responsibility to close it and make sure there's no
178
+ * file descriptor leak.
179
+ *
180
+ * By default, the stream will emit a `'close'` event after it has been
181
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
182
+ * @since v16.11.0
183
+ */
184
+ createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
185
+ /**
186
+ * Forces all currently queued I/O operations associated with the file to the
187
+ * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details.
188
+ *
189
+ * Unlike `filehandle.sync` this method does not flush modified metadata.
190
+ * @since v10.0.0
191
+ * @return Fulfills with `undefined` upon success.
192
+ */
193
+ datasync(): Promise<void>;
194
+ /**
195
+ * Request that all data for the open file descriptor is flushed to the storage
196
+ * device. The specific implementation is operating system and device specific.
197
+ * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
198
+ * @since v10.0.0
199
+ * @return Fufills with `undefined` upon success.
200
+ */
201
+ sync(): Promise<void>;
202
+ /**
203
+ * Reads data from the file and stores that in the given buffer.
204
+ *
205
+ * If the file is not modified concurrently, the end-of-file is reached when the
206
+ * number of bytes read is zero.
207
+ * @since v10.0.0
208
+ * @param buffer A buffer that will be filled with the file data read.
209
+ * @param offset The location in the buffer at which to start filling.
210
+ * @param length The number of bytes to read.
211
+ * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
212
+ * integer, the current file position will remain unchanged.
213
+ * @return Fulfills upon success with an object with two properties:
214
+ */
215
+ read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
216
+ read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
217
+ /**
218
+ * Returns a `ReadableStream` that may be used to read the files data.
219
+ *
220
+ * An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
221
+ * or closing.
222
+ *
223
+ * ```js
224
+ * import { open } from 'node:fs/promises';
225
+ *
226
+ * const file = await open('./some/file/to/read');
227
+ *
228
+ * for await (const chunk of file.readableWebStream())
229
+ * console.log(chunk);
230
+ *
231
+ * await file.close();
232
+ * ```
233
+ *
234
+ * While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method.
235
+ *
236
+ * @since v17.0.0
237
+ * @experimental
238
+ */
239
+ readableWebStream(): ReadableStream;
240
+ /**
241
+ * Asynchronously reads the entire contents of a file.
242
+ *
243
+ * If `options` is a string, then it specifies the `encoding`.
244
+ *
245
+ * The `FileHandle` has to support reading.
246
+ *
247
+ * If one or more `filehandle.read()` calls are made on a file handle and then a`filehandle.readFile()` call is made, the data will be read from the current
248
+ * position till the end of the file. It doesn't always read from the beginning
249
+ * of the file.
250
+ * @since v10.0.0
251
+ * @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the
252
+ * data will be a string.
253
+ */
254
+ readFile(
255
+ options?: {
256
+ encoding?: null | undefined;
257
+ flag?: OpenMode | undefined;
258
+ } | null
259
+ ): Promise<Buffer>;
260
+ /**
261
+ * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
262
+ * The `FileHandle` must have been opened for reading.
263
+ * @param options An object that may contain an optional flag.
264
+ * If a flag is not provided, it defaults to `'r'`.
265
+ */
266
+ readFile(
267
+ options:
268
+ | {
269
+ encoding: BufferEncoding;
270
+ flag?: OpenMode | undefined;
271
+ }
272
+ | BufferEncoding
273
+ ): Promise<string>;
274
+ /**
275
+ * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
276
+ * The `FileHandle` must have been opened for reading.
277
+ * @param options An object that may contain an optional flag.
278
+ * If a flag is not provided, it defaults to `'r'`.
279
+ */
280
+ readFile(
281
+ options?:
282
+ | (ObjectEncodingOptions & {
283
+ flag?: OpenMode | undefined;
284
+ })
285
+ | BufferEncoding
286
+ | null
287
+ ): Promise<string | Buffer>;
288
+ /**
289
+ * Convenience method to create a `readline` interface and stream over the file. For example:
290
+ *
291
+ * ```js
292
+ * import { open } from 'node:fs/promises';
293
+ *
294
+ * const file = await open('./some/file/to/read');
295
+ *
296
+ * for await (const line of file.readLines()) {
297
+ * console.log(line);
298
+ * }
299
+ * ```
300
+ *
301
+ * @since v18.11.0
302
+ * @param options See `filehandle.createReadStream()` for the options.
303
+ */
304
+ readLines(options?: CreateReadStreamOptions): ReadlineInterface;
305
+ /**
306
+ * @since v10.0.0
307
+ * @return Fulfills with an {fs.Stats} for the file.
308
+ */
309
+ stat(
310
+ opts?: StatOptions & {
311
+ bigint?: false | undefined;
312
+ }
313
+ ): Promise<Stats>;
314
+ stat(
315
+ opts: StatOptions & {
316
+ bigint: true;
317
+ }
318
+ ): Promise<BigIntStats>;
319
+ stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
320
+ /**
321
+ * Truncates the file.
322
+ *
323
+ * If the file was larger than `len` bytes, only the first `len` bytes will be
324
+ * retained in the file.
325
+ *
326
+ * The following example retains only the first four bytes of the file:
327
+ *
328
+ * ```js
329
+ * import { open } from 'fs/promises';
330
+ *
331
+ * let filehandle = null;
332
+ * try {
333
+ * filehandle = await open('temp.txt', 'r+');
334
+ * await filehandle.truncate(4);
335
+ * } finally {
336
+ * await filehandle?.close();
337
+ * }
338
+ * ```
339
+ *
340
+ * If the file previously was shorter than `len` bytes, it is extended, and the
341
+ * extended part is filled with null bytes (`'\0'`):
342
+ *
343
+ * If `len` is negative then `0` will be used.
344
+ * @since v10.0.0
345
+ * @param [len=0]
346
+ * @return Fulfills with `undefined` upon success.
347
+ */
348
+ truncate(len?: number): Promise<void>;
349
+ /**
350
+ * Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
351
+ * @since v10.0.0
352
+ */
353
+ utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
354
+ /**
355
+ * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
356
+ * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
357
+ * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
358
+ * The promise is resolved with no arguments upon success.
359
+ *
360
+ * If `options` is a string, then it specifies the `encoding`.
361
+ *
362
+ * The `FileHandle` has to support writing.
363
+ *
364
+ * It is unsafe to use `filehandle.writeFile()` multiple times on the same file
365
+ * without waiting for the promise to be resolved (or rejected).
366
+ *
367
+ * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
368
+ * current position till the end of the file. It doesn't always write from the
369
+ * beginning of the file.
370
+ * @since v10.0.0
371
+ */
372
+ writeFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null): Promise<void>;
373
+ /**
374
+ * Write `buffer` to the file.
375
+ *
376
+ * The promise is resolved with an object containing two properties:
377
+ *
378
+ * It is unsafe to use `filehandle.write()` multiple times on the same file
379
+ * without waiting for the promise to be resolved (or rejected). For this
380
+ * scenario, use `filehandle.createWriteStream()`.
381
+ *
382
+ * On Linux, positional writes do not work when the file is opened in append mode.
383
+ * The kernel ignores the position argument and always appends the data to
384
+ * the end of the file.
385
+ * @since v10.0.0
386
+ * @param [offset=0] The start position from within `buffer` where the data to write begins.
387
+ * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
388
+ * @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
389
+ * See the POSIX pwrite(2) documentation for more detail.
390
+ */
391
+ write<TBuffer extends Uint8Array>(
392
+ buffer: TBuffer,
393
+ offset?: number | null,
394
+ length?: number | null,
395
+ position?: number | null
396
+ ): Promise<{
397
+ bytesWritten: number;
398
+ buffer: TBuffer;
399
+ }>;
400
+ write(
401
+ data: string,
402
+ position?: number | null,
403
+ encoding?: BufferEncoding | null
404
+ ): Promise<{
405
+ bytesWritten: number;
406
+ buffer: string;
407
+ }>;
408
+ /**
409
+ * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
410
+ *
411
+ * The promise is resolved with an object containing a two properties:
412
+ *
413
+ * It is unsafe to call `writev()` multiple times on the same file without waiting
414
+ * for the promise to be resolved (or rejected).
415
+ *
416
+ * On Linux, positional writes don't work when the file is opened in append mode.
417
+ * The kernel ignores the position argument and always appends the data to
418
+ * the end of the file.
419
+ * @since v12.9.0
420
+ * @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
421
+ * position.
422
+ */
423
+ writev(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
424
+ /**
425
+ * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
426
+ * @since v13.13.0, v12.17.0
427
+ * @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
428
+ * @return Fulfills upon success an object containing two properties:
429
+ */
430
+ readv(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
431
+ /**
432
+ * Closes the file handle after waiting for any pending operation on the handle to
433
+ * complete.
434
+ *
435
+ * ```js
436
+ * import { open } from 'fs/promises';
437
+ *
438
+ * let filehandle;
439
+ * try {
440
+ * filehandle = await open('thefile.txt', 'r');
441
+ * } finally {
442
+ * await filehandle?.close();
443
+ * }
444
+ * ```
445
+ * @since v10.0.0
446
+ * @return Fulfills with `undefined` upon success.
447
+ */
448
+ close(): Promise<void>;
449
+ }
450
+
451
+ const constants: typeof fsConstants;
452
+
453
+ /**
454
+ * Tests a user's permissions for the file or directory specified by `path`.
455
+ * The `mode` argument is an optional integer that specifies the accessibility
456
+ * checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
457
+ * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
458
+ * possible values of `mode`.
459
+ *
460
+ * If the accessibility check is successful, the promise is resolved with no
461
+ * value. If any of the accessibility checks fail, the promise is rejected
462
+ * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
463
+ * written by the current process.
464
+ *
465
+ * ```js
466
+ * import { access } from 'fs/promises';
467
+ * import { constants } from 'fs';
468
+ *
469
+ * try {
470
+ * await access('/etc/passwd', constants.R_OK | constants.W_OK);
471
+ * console.log('can access');
472
+ * } catch {
473
+ * console.error('cannot access');
474
+ * }
475
+ * ```
476
+ *
477
+ * Using `fsPromises.access()` to check for the accessibility of a file before
478
+ * calling `fsPromises.open()` is not recommended. Doing so introduces a race
479
+ * condition, since other processes may change the file's state between the two
480
+ * calls. Instead, user code should open/read/write the file directly and handle
481
+ * the error raised if the file is not accessible.
482
+ * @since v10.0.0
483
+ * @param [mode=fs.constants.F_OK]
484
+ * @return Fulfills with `undefined` upon success.
485
+ */
486
+ function access(path: PathLike, mode?: number): Promise<void>;
487
+ /**
488
+ * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
489
+ * already exists.
490
+ *
491
+ * No guarantees are made about the atomicity of the copy operation. If an
492
+ * error occurs after the destination file has been opened for writing, an attempt
493
+ * will be made to remove the destination.
494
+ *
495
+ * ```js
496
+ * import { constants } from 'fs';
497
+ * import { copyFile } from 'fs/promises';
498
+ *
499
+ * try {
500
+ * await copyFile('source.txt', 'destination.txt');
501
+ * console.log('source.txt was copied to destination.txt');
502
+ * } catch {
503
+ * console.log('The file could not be copied');
504
+ * }
505
+ *
506
+ * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
507
+ * try {
508
+ * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
509
+ * console.log('source.txt was copied to destination.txt');
510
+ * } catch {
511
+ * console.log('The file could not be copied');
512
+ * }
513
+ * ```
514
+ * @since v10.0.0
515
+ * @param src source filename to copy
516
+ * @param dest destination filename of the copy operation
517
+ * @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
518
+ * `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)
519
+ * @return Fulfills with `undefined` upon success.
520
+ */
521
+ function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
522
+ /**
523
+ * Opens a `FileHandle`.
524
+ *
525
+ * Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.
526
+ *
527
+ * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
528
+ * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
529
+ * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
530
+ * @since v10.0.0
531
+ * @param [flags='r'] See `support of file system `flags``.
532
+ * @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
533
+ * @return Fulfills with a {FileHandle} object.
534
+ */
535
+ function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
536
+ /**
537
+ * Renames `oldPath` to `newPath`.
538
+ * @since v10.0.0
539
+ * @return Fulfills with `undefined` upon success.
540
+ */
541
+ function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
542
+ /**
543
+ * Truncates (shortens or extends the length) of the content at `path` to `len`bytes.
544
+ * @since v10.0.0
545
+ * @param [len=0]
546
+ * @return Fulfills with `undefined` upon success.
547
+ */
548
+ function truncate(path: PathLike, len?: number): Promise<void>;
549
+ /**
550
+ * Removes the directory identified by `path`.
551
+ *
552
+ * Using `fsPromises.rmdir()` on a file (not a directory) results in the
553
+ * promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`error on POSIX.
554
+ *
555
+ * To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`.
556
+ * @since v10.0.0
557
+ * @return Fulfills with `undefined` upon success.
558
+ */
559
+ function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
560
+ /**
561
+ * Removes files and directories (modeled on the standard POSIX `rm` utility).
562
+ * @since v14.14.0
563
+ * @return Fulfills with `undefined` upon success.
564
+ */
565
+ function rm(path: PathLike, options?: RmOptions): Promise<void>;
566
+ /**
567
+ * Asynchronously creates a directory.
568
+ *
569
+ * The optional `options` argument can be an integer specifying `mode` (permission
570
+ * and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory
571
+ * that exists results in a
572
+ * rejection only when `recursive` is false.
573
+ * @since v10.0.0
574
+ * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
575
+ */
576
+ function mkdir(
577
+ path: PathLike,
578
+ options: MakeDirectoryOptions & {
579
+ recursive: true;
580
+ }
581
+ ): Promise<string | undefined>;
582
+ /**
583
+ * Asynchronous mkdir(2) - create a directory.
584
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
585
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
586
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
587
+ */
588
+ function mkdir(
589
+ path: PathLike,
590
+ options?:
591
+ | Mode
592
+ | (MakeDirectoryOptions & {
593
+ recursive?: false | undefined;
594
+ })
595
+ | null
596
+ ): Promise<void>;
597
+ /**
598
+ * Asynchronous mkdir(2) - create a directory.
599
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
600
+ * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
601
+ * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
602
+ */
603
+ function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
604
+ /**
605
+ * Reads the contents of a directory.
606
+ *
607
+ * The optional `options` argument can be a string specifying an encoding, or an
608
+ * object with an `encoding` property specifying the character encoding to use for
609
+ * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
610
+ * will be passed as `Buffer` objects.
611
+ *
612
+ * If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects.
613
+ *
614
+ * ```js
615
+ * import { readdir } from 'fs/promises';
616
+ *
617
+ * try {
618
+ * const files = await readdir(path);
619
+ * for (const file of files)
620
+ * console.log(file);
621
+ * } catch (err) {
622
+ * console.error(err);
623
+ * }
624
+ * ```
625
+ * @since v10.0.0
626
+ * @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`.
627
+ */
628
+ function readdir(
629
+ path: PathLike,
630
+ options?:
631
+ | (ObjectEncodingOptions & {
632
+ withFileTypes?: false | undefined;
633
+ })
634
+ | BufferEncoding
635
+ | null
636
+ ): Promise<string[]>;
637
+ /**
638
+ * Asynchronous readdir(3) - read a directory.
639
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
640
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
641
+ */
642
+ function readdir(
643
+ path: PathLike,
644
+ options:
645
+ | {
646
+ encoding: 'buffer';
647
+ withFileTypes?: false | undefined;
648
+ }
649
+ | 'buffer'
650
+ ): Promise<Buffer[]>;
651
+ /**
652
+ * Asynchronous readdir(3) - read a directory.
653
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
654
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
655
+ */
656
+ function readdir(
657
+ path: PathLike,
658
+ options?:
659
+ | (ObjectEncodingOptions & {
660
+ withFileTypes?: false | undefined;
661
+ })
662
+ | BufferEncoding
663
+ | null
664
+ ): Promise<string[] | Buffer[]>;
665
+ /**
666
+ * Asynchronous readdir(3) - read a directory.
667
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
668
+ * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
669
+ */
670
+ function readdir(
671
+ path: PathLike,
672
+ options: ObjectEncodingOptions & {
673
+ withFileTypes: true;
674
+ }
675
+ ): Promise<Dirent[]>;
676
+ /**
677
+ * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
678
+ * resolved with the`linkString` upon success.
679
+ *
680
+ * The optional `options` argument can be a string specifying an encoding, or an
681
+ * object with an `encoding` property specifying the character encoding to use for
682
+ * the link path returned. If the `encoding` is set to `'buffer'`, the link path
683
+ * returned will be passed as a `Buffer` object.
684
+ * @since v10.0.0
685
+ * @return Fulfills with the `linkString` upon success.
686
+ */
687
+ function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
688
+ /**
689
+ * Asynchronous readlink(2) - read value of a symbolic link.
690
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
691
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
692
+ */
693
+ function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
694
+ /**
695
+ * Asynchronous readlink(2) - read value of a symbolic link.
696
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
697
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
698
+ */
699
+ function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
700
+ /**
701
+ * Creates a symbolic link.
702
+ *
703
+ * The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. Windows junction points require the destination path
704
+ * to be absolute. When using `'junction'`, the `target` argument will
705
+ * automatically be normalized to absolute path.
706
+ * @since v10.0.0
707
+ * @param [type='file']
708
+ * @return Fulfills with `undefined` upon success.
709
+ */
710
+ function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
711
+ /**
712
+ * Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link,
713
+ * in which case the link itself is stat-ed, not the file that it refers to.
714
+ * Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.
715
+ * @since v10.0.0
716
+ * @return Fulfills with the {fs.Stats} object for the given symbolic link `path`.
717
+ */
718
+ function lstat(
719
+ path: PathLike,
720
+ opts?: StatOptions & {
721
+ bigint?: false | undefined;
722
+ }
723
+ ): Promise<Stats>;
724
+ function lstat(
725
+ path: PathLike,
726
+ opts: StatOptions & {
727
+ bigint: true;
728
+ }
729
+ ): Promise<BigIntStats>;
730
+ function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
731
+ /**
732
+ * @since v10.0.0
733
+ * @return Fulfills with the {fs.Stats} object for the given `path`.
734
+ */
735
+ function stat(
736
+ path: PathLike,
737
+ opts?: StatOptions & {
738
+ bigint?: false | undefined;
739
+ }
740
+ ): Promise<Stats>;
741
+ function stat(
742
+ path: PathLike,
743
+ opts: StatOptions & {
744
+ bigint: true;
745
+ }
746
+ ): Promise<BigIntStats>;
747
+ function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
748
+ /**
749
+ * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
750
+ * @since v10.0.0
751
+ * @return Fulfills with `undefined` upon success.
752
+ */
753
+ function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
754
+ /**
755
+ * If `path` refers to a symbolic link, then the link is removed without affecting
756
+ * the file or directory to which that link refers. If the `path` refers to a file
757
+ * path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail.
758
+ * @since v10.0.0
759
+ * @return Fulfills with `undefined` upon success.
760
+ */
761
+ function unlink(path: PathLike): Promise<void>;
762
+ /**
763
+ * Changes the permissions of a file.
764
+ * @since v10.0.0
765
+ * @return Fulfills with `undefined` upon success.
766
+ */
767
+ function chmod(path: PathLike, mode: Mode): Promise<void>;
768
+ /**
769
+ * Changes the permissions on a symbolic link.
770
+ *
771
+ * This method is only implemented on macOS.
772
+ * @deprecated Since v10.0.0
773
+ * @return Fulfills with `undefined` upon success.
774
+ */
775
+ function lchmod(path: PathLike, mode: Mode): Promise<void>;
776
+ /**
777
+ * Changes the ownership on a symbolic link.
778
+ * @since v10.0.0
779
+ * @return Fulfills with `undefined` upon success.
780
+ */
781
+ function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
782
+ /**
783
+ * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a
784
+ * symbolic link, then the link is not dereferenced: instead, the timestamps of
785
+ * the symbolic link itself are changed.
786
+ * @since v14.5.0, v12.19.0
787
+ * @return Fulfills with `undefined` upon success.
788
+ */
789
+ function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
790
+ /**
791
+ * Changes the ownership of a file.
792
+ * @since v10.0.0
793
+ * @return Fulfills with `undefined` upon success.
794
+ */
795
+ function chown(path: PathLike, uid: number, gid: number): Promise<void>;
796
+ /**
797
+ * Change the file system timestamps of the object referenced by `path`.
798
+ *
799
+ * The `atime` and `mtime` arguments follow these rules:
800
+ *
801
+ * * Values can be either numbers representing Unix epoch time, `Date`s, or a
802
+ * numeric string like `'123456789.0'`.
803
+ * * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown.
804
+ * @since v10.0.0
805
+ * @return Fulfills with `undefined` upon success.
806
+ */
807
+ function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
808
+ /**
809
+ * Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function.
810
+ *
811
+ * Only paths that can be converted to UTF8 strings are supported.
812
+ *
813
+ * The optional `options` argument can be a string specifying an encoding, or an
814
+ * object with an `encoding` property specifying the character encoding to use for
815
+ * the path. If the `encoding` is set to `'buffer'`, the path returned will be
816
+ * passed as a `Buffer` object.
817
+ *
818
+ * On Linux, when Node.js is linked against musl libc, the procfs file system must
819
+ * be mounted on `/proc` in order for this function to work. Glibc does not have
820
+ * this restriction.
821
+ * @since v10.0.0
822
+ * @return Fulfills with the resolved path upon success.
823
+ */
824
+ function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
825
+ /**
826
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
827
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
828
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
829
+ */
830
+ function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
831
+ /**
832
+ * Asynchronous realpath(3) - return the canonicalized absolute pathname.
833
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
834
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
835
+ */
836
+ function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
837
+ /**
838
+ * Creates a unique temporary directory. A unique directory name is generated by
839
+ * appending six random characters to the end of the provided `prefix`. Due to
840
+ * platform inconsistencies, avoid trailing `X` characters in `prefix`. Some
841
+ * platforms, notably the BSDs, can return more than six random characters, and
842
+ * replace trailing `X` characters in `prefix` with random characters.
843
+ *
844
+ * The optional `options` argument can be a string specifying an encoding, or an
845
+ * object with an `encoding` property specifying the character encoding to use.
846
+ *
847
+ * ```js
848
+ * import { mkdtemp } from 'fs/promises';
849
+ *
850
+ * try {
851
+ * await mkdtemp(path.join(os.tmpdir(), 'foo-'));
852
+ * } catch (err) {
853
+ * console.error(err);
854
+ * }
855
+ * ```
856
+ *
857
+ * The `fsPromises.mkdtemp()` method will append the six randomly selected
858
+ * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing
859
+ * platform-specific path separator
860
+ * (`require('path').sep`).
861
+ * @since v10.0.0
862
+ * @return Fulfills with a string containing the filesystem path of the newly created temporary directory.
863
+ */
864
+ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
865
+ /**
866
+ * Asynchronously creates a unique temporary directory.
867
+ * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
868
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
869
+ */
870
+ function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
871
+ /**
872
+ * Asynchronously creates a unique temporary directory.
873
+ * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
874
+ * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
875
+ */
876
+ function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
877
+ /**
878
+ * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
879
+ * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
880
+ * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
881
+ *
882
+ * The `encoding` option is ignored if `data` is a buffer.
883
+ *
884
+ * If `options` is a string, then it specifies the encoding.
885
+ *
886
+ * The `mode` option only affects the newly created file. See `fs.open()` for more details.
887
+ *
888
+ * Any specified `FileHandle` has to support writing.
889
+ *
890
+ * It is unsafe to use `fsPromises.writeFile()` multiple times on the same file
891
+ * without waiting for the promise to be settled.
892
+ *
893
+ * Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
894
+ * method that performs multiple `write` calls internally to write the buffer
895
+ * passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
896
+ *
897
+ * It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
898
+ * Cancelation is "best effort", and some amount of data is likely still
899
+ * to be written.
900
+ *
901
+ * ```js
902
+ * import { writeFile } from 'fs/promises';
903
+ * import { Buffer } from 'buffer';
904
+ *
905
+ * try {
906
+ * const controller = new AbortController();
907
+ * const { signal } = controller;
908
+ * const data = new Uint8Array(Buffer.from('Hello Node.js'));
909
+ * const promise = writeFile('message.txt', data, { signal });
910
+ *
911
+ * // Abort the request before the promise settles.
912
+ * controller.abort();
913
+ *
914
+ * await promise;
915
+ * } catch (err) {
916
+ * // When a request is aborted - err is an AbortError
917
+ * console.error(err);
918
+ * }
919
+ * ```
920
+ *
921
+ * Aborting an ongoing request does not abort individual operating
922
+ * system requests but rather the internal buffering `fs.writeFile` performs.
923
+ * @since v10.0.0
924
+ * @param file filename or `FileHandle`
925
+ * @return Fulfills with `undefined` upon success.
926
+ */
927
+ function writeFile(
928
+ file: PathLike | FileHandle,
929
+ data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
930
+ options?:
931
+ | (ObjectEncodingOptions & {
932
+ mode?: Mode | undefined;
933
+ flag?: OpenMode | undefined;
934
+ } & Abortable)
935
+ | BufferEncoding
936
+ | null
937
+ ): Promise<void>;
938
+ /**
939
+ * Asynchronously append data to a file, creating the file if it does not yet
940
+ * exist. `data` can be a string or a `Buffer`.
941
+ *
942
+ * If `options` is a string, then it specifies the `encoding`.
943
+ *
944
+ * The `mode` option only affects the newly created file. See `fs.open()` for more details.
945
+ *
946
+ * The `path` may be specified as a `FileHandle` that has been opened
947
+ * for appending (using `fsPromises.open()`).
948
+ * @since v10.0.0
949
+ * @param path filename or {FileHandle}
950
+ * @return Fulfills with `undefined` upon success.
951
+ */
952
+ function appendFile(path: PathLike | FileHandle, data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
953
+ /**
954
+ * Asynchronously reads the entire contents of a file.
955
+ *
956
+ * If no encoding is specified (using `options.encoding`), the data is returned
957
+ * as a `Buffer` object. Otherwise, the data will be a string.
958
+ *
959
+ * If `options` is a string, then it specifies the encoding.
960
+ *
961
+ * When the `path` is a directory, the behavior of `fsPromises.readFile()` is
962
+ * platform-specific. On macOS, Linux, and Windows, the promise will be rejected
963
+ * with an error. On FreeBSD, a representation of the directory's contents will be
964
+ * returned.
965
+ *
966
+ * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
967
+ * request is aborted the promise returned is rejected with an `AbortError`:
968
+ *
969
+ * ```js
970
+ * import { readFile } from 'fs/promises';
971
+ *
972
+ * try {
973
+ * const controller = new AbortController();
974
+ * const { signal } = controller;
975
+ * const promise = readFile(fileName, { signal });
976
+ *
977
+ * // Abort the request before the promise settles.
978
+ * controller.abort();
979
+ *
980
+ * await promise;
981
+ * } catch (err) {
982
+ * // When a request is aborted - err is an AbortError
983
+ * console.error(err);
984
+ * }
985
+ * ```
986
+ *
987
+ * Aborting an ongoing request does not abort individual operating
988
+ * system requests but rather the internal buffering `fs.readFile` performs.
989
+ *
990
+ * Any specified `FileHandle` has to support reading.
991
+ * @since v10.0.0
992
+ * @param path filename or `FileHandle`
993
+ * @return Fulfills with the contents of the file.
994
+ */
995
+ function readFile(
996
+ path: PathLike | FileHandle,
997
+ options?:
998
+ | ({
999
+ encoding?: null | undefined;
1000
+ flag?: OpenMode | undefined;
1001
+ } & Abortable)
1002
+ | null
1003
+ ): Promise<Buffer>;
1004
+ /**
1005
+ * Asynchronously reads the entire contents of a file.
1006
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1007
+ * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1008
+ * @param options An object that may contain an optional flag.
1009
+ * If a flag is not provided, it defaults to `'r'`.
1010
+ */
1011
+ function readFile(
1012
+ path: PathLike | FileHandle,
1013
+ options:
1014
+ | ({
1015
+ encoding: BufferEncoding;
1016
+ flag?: OpenMode | undefined;
1017
+ } & Abortable)
1018
+ | BufferEncoding
1019
+ ): Promise<string>;
1020
+ /**
1021
+ * Asynchronously reads the entire contents of a file.
1022
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1023
+ * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1024
+ * @param options An object that may contain an optional flag.
1025
+ * If a flag is not provided, it defaults to `'r'`.
1026
+ */
1027
+ function readFile(
1028
+ path: PathLike | FileHandle,
1029
+ options?:
1030
+ | (ObjectEncodingOptions &
1031
+ Abortable & {
1032
+ flag?: OpenMode | undefined;
1033
+ })
1034
+ | BufferEncoding
1035
+ | null
1036
+ ): Promise<string | Buffer>;
1037
+ /**
1038
+ * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
1039
+ *
1040
+ * Creates an `fs.Dir`, which contains all further functions for reading from
1041
+ * and cleaning up the directory.
1042
+ *
1043
+ * The `encoding` option sets the encoding for the `path` while opening the
1044
+ * directory and subsequent read operations.
1045
+ *
1046
+ * Example using async iteration:
1047
+ *
1048
+ * ```js
1049
+ * import { opendir } from 'fs/promises';
1050
+ *
1051
+ * try {
1052
+ * const dir = await opendir('./');
1053
+ * for await (const dirent of dir)
1054
+ * console.log(dirent.name);
1055
+ * } catch (err) {
1056
+ * console.error(err);
1057
+ * }
1058
+ * ```
1059
+ *
1060
+ * When using the async iterator, the `fs.Dir` object will be automatically
1061
+ * closed after the iterator exits.
1062
+ * @since v12.12.0
1063
+ * @return Fulfills with an {fs.Dir}.
1064
+ */
1065
+ function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
1066
+ /**
1067
+ * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1068
+ *
1069
+ * ```js
1070
+ * const { watch } = require('fs/promises');
1071
+ *
1072
+ * const ac = new AbortController();
1073
+ * const { signal } = ac;
1074
+ * setTimeout(() => ac.abort(), 10000);
1075
+ *
1076
+ * (async () => {
1077
+ * try {
1078
+ * const watcher = watch(__filename, { signal });
1079
+ * for await (const event of watcher)
1080
+ * console.log(event);
1081
+ * } catch (err) {
1082
+ * if (err.name === 'AbortError')
1083
+ * return;
1084
+ * throw err;
1085
+ * }
1086
+ * })();
1087
+ * ```
1088
+ *
1089
+ * On most platforms, `'rename'` is emitted whenever a filename appears or
1090
+ * disappears in the directory.
1091
+ *
1092
+ * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
1093
+ * @since v15.9.0, v14.18.0
1094
+ * @return of objects with the properties:
1095
+ */
1096
+ function watch(
1097
+ filename: PathLike,
1098
+ options:
1099
+ | (WatchOptions & {
1100
+ encoding: 'buffer';
1101
+ })
1102
+ | 'buffer'
1103
+ ): AsyncIterable<FileChangeInfo<Buffer>>;
1104
+ /**
1105
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1106
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1107
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1108
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
1109
+ * If `persistent` is not supplied, the default of `true` is used.
1110
+ * If `recursive` is not supplied, the default of `false` is used.
1111
+ */
1112
+ function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
1113
+ /**
1114
+ * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1115
+ * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1116
+ * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1117
+ * If `encoding` is not supplied, the default of `'utf8'` is used.
1118
+ * If `persistent` is not supplied, the default of `true` is used.
1119
+ * If `recursive` is not supplied, the default of `false` is used.
1120
+ */
1121
+ function watch(filename: PathLike, options: WatchOptions | string): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
1122
+ /**
1123
+ * Asynchronously copies the entire directory structure from `src` to `dest`,
1124
+ * including subdirectories and files.
1125
+ *
1126
+ * When copying a directory to another directory, globs are not supported and
1127
+ * behavior is similar to `cp dir1/ dir2/`.
1128
+ * @since v16.7.0
1129
+ * @experimental
1130
+ * @param src source path to copy.
1131
+ * @param dest destination path to copy to.
1132
+ * @return Fulfills with `undefined` upon success.
1133
+ */
1134
+ function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1135
+ }
1136
+ declare module 'node:fs/promises' {
1137
+ export * from 'fs/promises';
1138
+ }
node_modules/@types/node/globals.d.ts ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Declare "static" methods in Error
2
+ interface ErrorConstructor {
3
+ /** Create .stack property on a target object */
4
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
5
+
6
+ /**
7
+ * Optional override for formatting stack traces
8
+ *
9
+ * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
10
+ */
11
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
12
+
13
+ stackTraceLimit: number;
14
+ }
15
+
16
+ /*-----------------------------------------------*
17
+ * *
18
+ * GLOBAL *
19
+ * *
20
+ ------------------------------------------------*/
21
+
22
+ // For backwards compability
23
+ interface NodeRequire extends NodeJS.Require { }
24
+ interface RequireResolve extends NodeJS.RequireResolve { }
25
+ interface NodeModule extends NodeJS.Module { }
26
+
27
+ declare var process: NodeJS.Process;
28
+ declare var console: Console;
29
+
30
+ declare var __filename: string;
31
+ declare var __dirname: string;
32
+
33
+ declare var require: NodeRequire;
34
+ declare var module: NodeModule;
35
+
36
+ // Same as module.exports
37
+ declare var exports: any;
38
+
39
+ /**
40
+ * Only available if `--expose-gc` is passed to the process.
41
+ */
42
+ declare var gc: undefined | (() => void);
43
+
44
+ //#region borrowed
45
+ // from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
46
+ /** A controller object that allows you to abort one or more DOM requests as and when desired. */
47
+ interface AbortController {
48
+ /**
49
+ * Returns the AbortSignal object associated with this object.
50
+ */
51
+
52
+ readonly signal: AbortSignal;
53
+ /**
54
+ * Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
55
+ */
56
+ abort(): void;
57
+ }
58
+
59
+ /** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
60
+ interface AbortSignal extends EventTarget {
61
+ /**
62
+ * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
63
+ */
64
+ readonly aborted: boolean;
65
+ }
66
+
67
+ declare var AbortController: typeof globalThis extends {onmessage: any; AbortController: infer T}
68
+ ? T
69
+ : {
70
+ prototype: AbortController;
71
+ new(): AbortController;
72
+ };
73
+
74
+ declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal: infer T}
75
+ ? T
76
+ : {
77
+ prototype: AbortSignal;
78
+ new(): AbortSignal;
79
+ abort(reason?: any): AbortSignal;
80
+ timeout(milliseconds: number): AbortSignal;
81
+ };
82
+ //#endregion borrowed
83
+
84
+ //#region ArrayLike.at()
85
+ interface RelativeIndexable<T> {
86
+ /**
87
+ * Takes an integer value and returns the item at that index,
88
+ * allowing for positive and negative integers.
89
+ * Negative integers count back from the last item in the array.
90
+ */
91
+ at(index: number): T | undefined;
92
+ }
93
+ interface String extends RelativeIndexable<string> {}
94
+ interface Array<T> extends RelativeIndexable<T> {}
95
+ interface ReadonlyArray<T> extends RelativeIndexable<T> {}
96
+ interface Int8Array extends RelativeIndexable<number> {}
97
+ interface Uint8Array extends RelativeIndexable<number> {}
98
+ interface Uint8ClampedArray extends RelativeIndexable<number> {}
99
+ interface Int16Array extends RelativeIndexable<number> {}
100
+ interface Uint16Array extends RelativeIndexable<number> {}
101
+ interface Int32Array extends RelativeIndexable<number> {}
102
+ interface Uint32Array extends RelativeIndexable<number> {}
103
+ interface Float32Array extends RelativeIndexable<number> {}
104
+ interface Float64Array extends RelativeIndexable<number> {}
105
+ interface BigInt64Array extends RelativeIndexable<bigint> {}
106
+ interface BigUint64Array extends RelativeIndexable<bigint> {}
107
+ //#endregion ArrayLike.at() end
108
+
109
+ /**
110
+ * @since v17.0.0
111
+ *
112
+ * Creates a deep clone of an object.
113
+ */
114
+ declare function structuredClone<T>(
115
+ value: T,
116
+ transfer?: { transfer: ReadonlyArray<import('worker_threads').TransferListItem> },
117
+ ): T;
118
+
119
+ /*----------------------------------------------*
120
+ * *
121
+ * GLOBAL INTERFACES *
122
+ * *
123
+ *-----------------------------------------------*/
124
+ declare namespace NodeJS {
125
+ interface CallSite {
126
+ /**
127
+ * Value of "this"
128
+ */
129
+ getThis(): unknown;
130
+
131
+ /**
132
+ * Type of "this" as a string.
133
+ * This is the name of the function stored in the constructor field of
134
+ * "this", if available. Otherwise the object's [[Class]] internal
135
+ * property.
136
+ */
137
+ getTypeName(): string | null;
138
+
139
+ /**
140
+ * Current function
141
+ */
142
+ getFunction(): Function | undefined;
143
+
144
+ /**
145
+ * Name of the current function, typically its name property.
146
+ * If a name property is not available an attempt will be made to try
147
+ * to infer a name from the function's context.
148
+ */
149
+ getFunctionName(): string | null;
150
+
151
+ /**
152
+ * Name of the property [of "this" or one of its prototypes] that holds
153
+ * the current function
154
+ */
155
+ getMethodName(): string | null;
156
+
157
+ /**
158
+ * Name of the script [if this function was defined in a script]
159
+ */
160
+ getFileName(): string | null;
161
+
162
+ /**
163
+ * Current line number [if this function was defined in a script]
164
+ */
165
+ getLineNumber(): number | null;
166
+
167
+ /**
168
+ * Current column number [if this function was defined in a script]
169
+ */
170
+ getColumnNumber(): number | null;
171
+
172
+ /**
173
+ * A call site object representing the location where eval was called
174
+ * [if this function was created using a call to eval]
175
+ */
176
+ getEvalOrigin(): string | undefined;
177
+
178
+ /**
179
+ * Is this a toplevel invocation, that is, is "this" the global object?
180
+ */
181
+ isToplevel(): boolean;
182
+
183
+ /**
184
+ * Does this call take place in code defined by a call to eval?
185
+ */
186
+ isEval(): boolean;
187
+
188
+ /**
189
+ * Is this call in native V8 code?
190
+ */
191
+ isNative(): boolean;
192
+
193
+ /**
194
+ * Is this a constructor call?
195
+ */
196
+ isConstructor(): boolean;
197
+ }
198
+
199
+ interface ErrnoException extends Error {
200
+ errno?: number | undefined;
201
+ code?: string | undefined;
202
+ path?: string | undefined;
203
+ syscall?: string | undefined;
204
+ }
205
+
206
+ interface ReadableStream extends EventEmitter {
207
+ readable: boolean;
208
+ read(size?: number): string | Buffer;
209
+ setEncoding(encoding: BufferEncoding): this;
210
+ pause(): this;
211
+ resume(): this;
212
+ isPaused(): boolean;
213
+ pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined; }): T;
214
+ unpipe(destination?: WritableStream): this;
215
+ unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
216
+ wrap(oldStream: ReadableStream): this;
217
+ [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
218
+ }
219
+
220
+ interface WritableStream extends EventEmitter {
221
+ writable: boolean;
222
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
223
+ write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
224
+ end(cb?: () => void): this;
225
+ end(data: string | Uint8Array, cb?: () => void): this;
226
+ end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
227
+ }
228
+
229
+ interface ReadWriteStream extends ReadableStream, WritableStream { }
230
+
231
+ interface RefCounted {
232
+ ref(): this;
233
+ unref(): this;
234
+ }
235
+
236
+ type TypedArray =
237
+ | Uint8Array
238
+ | Uint8ClampedArray
239
+ | Uint16Array
240
+ | Uint32Array
241
+ | Int8Array
242
+ | Int16Array
243
+ | Int32Array
244
+ | BigUint64Array
245
+ | BigInt64Array
246
+ | Float32Array
247
+ | Float64Array;
248
+ type ArrayBufferView = TypedArray | DataView;
249
+
250
+ interface Require {
251
+ (id: string): any;
252
+ resolve: RequireResolve;
253
+ cache: Dict<NodeModule>;
254
+ /**
255
+ * @deprecated
256
+ */
257
+ extensions: RequireExtensions;
258
+ main: Module | undefined;
259
+ }
260
+
261
+ interface RequireResolve {
262
+ (id: string, options?: { paths?: string[] | undefined; }): string;
263
+ paths(request: string): string[] | null;
264
+ }
265
+
266
+ interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
267
+ '.js': (m: Module, filename: string) => any;
268
+ '.json': (m: Module, filename: string) => any;
269
+ '.node': (m: Module, filename: string) => any;
270
+ }
271
+ interface Module {
272
+ /**
273
+ * `true` if the module is running during the Node.js preload
274
+ */
275
+ isPreloading: boolean;
276
+ exports: any;
277
+ require: Require;
278
+ id: string;
279
+ filename: string;
280
+ loaded: boolean;
281
+ /** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
282
+ parent: Module | null | undefined;
283
+ children: Module[];
284
+ /**
285
+ * @since v11.14.0
286
+ *
287
+ * The directory name of the module. This is usually the same as the path.dirname() of the module.id.
288
+ */
289
+ path: string;
290
+ paths: string[];
291
+ }
292
+
293
+ interface Dict<T> {
294
+ [key: string]: T | undefined;
295
+ }
296
+
297
+ interface ReadOnlyDict<T> {
298
+ readonly [key: string]: T | undefined;
299
+ }
300
+ }
node_modules/@types/node/globals.global.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ declare var global: typeof globalThis;
node_modules/@types/node/http.d.ts ADDED
@@ -0,0 +1,1651 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * To use the HTTP server and client one must `require('http')`.
3
+ *
4
+ * The HTTP interfaces in Node.js are designed to support many features
5
+ * of the protocol which have been traditionally difficult to use.
6
+ * In particular, large, possibly chunk-encoded, messages. The interface is
7
+ * careful to never buffer entire requests or responses, so the
8
+ * user is able to stream data.
9
+ *
10
+ * HTTP message headers are represented by an object like this:
11
+ *
12
+ * ```js
13
+ * { 'content-length': '123',
14
+ * 'content-type': 'text/plain',
15
+ * 'connection': 'keep-alive',
16
+ * 'host': 'example.com',
17
+ * 'accept': '*' }
18
+ * ```
19
+ *
20
+ * Keys are lowercased. Values are not modified.
21
+ *
22
+ * In order to support the full spectrum of possible HTTP applications, the Node.js
23
+ * HTTP API is very low-level. It deals with stream handling and message
24
+ * parsing only. It parses a message into headers and body but it does not
25
+ * parse the actual headers or the body.
26
+ *
27
+ * See `message.headers` for details on how duplicate headers are handled.
28
+ *
29
+ * The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For
30
+ * example, the previous message header object might have a `rawHeaders`list like the following:
31
+ *
32
+ * ```js
33
+ * [ 'ConTent-Length', '123456',
34
+ * 'content-LENGTH', '123',
35
+ * 'content-type', 'text/plain',
36
+ * 'CONNECTION', 'keep-alive',
37
+ * 'Host', 'example.com',
38
+ * 'accepT', '*' ]
39
+ * ```
40
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js)
41
+ */
42
+ declare module 'http' {
43
+ import * as stream from 'node:stream';
44
+ import { URL } from 'node:url';
45
+ import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net';
46
+ import { LookupOptions } from 'node:dns';
47
+ // incoming headers will never contain number
48
+ interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
49
+ accept?: string | undefined;
50
+ 'accept-language'?: string | undefined;
51
+ 'accept-patch'?: string | undefined;
52
+ 'accept-ranges'?: string | undefined;
53
+ 'access-control-allow-credentials'?: string | undefined;
54
+ 'access-control-allow-headers'?: string | undefined;
55
+ 'access-control-allow-methods'?: string | undefined;
56
+ 'access-control-allow-origin'?: string | undefined;
57
+ 'access-control-expose-headers'?: string | undefined;
58
+ 'access-control-max-age'?: string | undefined;
59
+ 'access-control-request-headers'?: string | undefined;
60
+ 'access-control-request-method'?: string | undefined;
61
+ age?: string | undefined;
62
+ allow?: string | undefined;
63
+ 'alt-svc'?: string | undefined;
64
+ authorization?: string | undefined;
65
+ 'cache-control'?: string | undefined;
66
+ connection?: string | undefined;
67
+ 'content-disposition'?: string | undefined;
68
+ 'content-encoding'?: string | undefined;
69
+ 'content-language'?: string | undefined;
70
+ 'content-length'?: string | undefined;
71
+ 'content-location'?: string | undefined;
72
+ 'content-range'?: string | undefined;
73
+ 'content-type'?: string | undefined;
74
+ cookie?: string | undefined;
75
+ date?: string | undefined;
76
+ etag?: string | undefined;
77
+ expect?: string | undefined;
78
+ expires?: string | undefined;
79
+ forwarded?: string | undefined;
80
+ from?: string | undefined;
81
+ host?: string | undefined;
82
+ 'if-match'?: string | undefined;
83
+ 'if-modified-since'?: string | undefined;
84
+ 'if-none-match'?: string | undefined;
85
+ 'if-unmodified-since'?: string | undefined;
86
+ 'last-modified'?: string | undefined;
87
+ location?: string | undefined;
88
+ origin?: string | undefined;
89
+ pragma?: string | undefined;
90
+ 'proxy-authenticate'?: string | undefined;
91
+ 'proxy-authorization'?: string | undefined;
92
+ 'public-key-pins'?: string | undefined;
93
+ range?: string | undefined;
94
+ referer?: string | undefined;
95
+ 'retry-after'?: string | undefined;
96
+ 'sec-websocket-accept'?: string | undefined;
97
+ 'sec-websocket-extensions'?: string | undefined;
98
+ 'sec-websocket-key'?: string | undefined;
99
+ 'sec-websocket-protocol'?: string | undefined;
100
+ 'sec-websocket-version'?: string | undefined;
101
+ 'set-cookie'?: string[] | undefined;
102
+ 'strict-transport-security'?: string | undefined;
103
+ tk?: string | undefined;
104
+ trailer?: string | undefined;
105
+ 'transfer-encoding'?: string | undefined;
106
+ upgrade?: string | undefined;
107
+ 'user-agent'?: string | undefined;
108
+ vary?: string | undefined;
109
+ via?: string | undefined;
110
+ warning?: string | undefined;
111
+ 'www-authenticate'?: string | undefined;
112
+ }
113
+ // outgoing headers allows numbers (as they are converted internally to strings)
114
+ type OutgoingHttpHeader = number | string | string[];
115
+ interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
116
+ interface ClientRequestArgs {
117
+ _defaultAgent?: Agent | undefined;
118
+ agent?: Agent | boolean | undefined;
119
+ auth?: string | null | undefined;
120
+ // https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
121
+ createConnection?:
122
+ | ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket)
123
+ | undefined;
124
+ defaultPort?: number | string | undefined;
125
+ family?: number | undefined;
126
+ headers?: OutgoingHttpHeaders | undefined;
127
+ hints?: LookupOptions['hints'];
128
+ host?: string | null | undefined;
129
+ hostname?: string | null | undefined;
130
+ insecureHTTPParser?: boolean | undefined;
131
+ localAddress?: string | undefined;
132
+ localPort?: number | undefined;
133
+ lookup?: LookupFunction | undefined;
134
+ /**
135
+ * @default 16384
136
+ */
137
+ maxHeaderSize?: number | undefined;
138
+ method?: string | undefined;
139
+ path?: string | null | undefined;
140
+ port?: number | string | null | undefined;
141
+ protocol?: string | null | undefined;
142
+ setHost?: boolean | undefined;
143
+ signal?: AbortSignal | undefined;
144
+ socketPath?: string | undefined;
145
+ timeout?: number | undefined;
146
+ uniqueHeaders?: Array<string | string[]> | undefined;
147
+ }
148
+ interface ServerOptions<
149
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
150
+ Response extends typeof ServerResponse = typeof ServerResponse,
151
+ > {
152
+ /**
153
+ * Specifies the `IncomingMessage` class to be used. Useful for extending the original `IncomingMessage`.
154
+ */
155
+ IncomingMessage?: Request | undefined;
156
+ /**
157
+ * Specifies the `ServerResponse` class to be used. Useful for extending the original `ServerResponse`.
158
+ */
159
+ ServerResponse?: Response | undefined;
160
+ /**
161
+ * Sets the timeout value in milliseconds for receiving the entire request from the client.
162
+ * @see Server.requestTimeout for more information.
163
+ * @default 300000
164
+ * @since v18.0.0
165
+ */
166
+ requestTimeout?: number | undefined;
167
+ /**
168
+ * The number of milliseconds of inactivity a server needs to wait for additional incoming data,
169
+ * after it has finished writing the last response, before a socket will be destroyed.
170
+ * @see Server.keepAliveTimeout for more information.
171
+ * @default 5000
172
+ * @since v18.0.0
173
+ */
174
+ keepAliveTimeout?: number | undefined;
175
+ /**
176
+ * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
177
+ * @default 30000
178
+ */
179
+ connectionsCheckingInterval?: number | undefined;
180
+ /**
181
+ * Use an insecure HTTP parser that accepts invalid HTTP headers when `true`.
182
+ * Using the insecure parser should be avoided.
183
+ * See --insecure-http-parser for more information.
184
+ * @default false
185
+ */
186
+ insecureHTTPParser?: boolean | undefined;
187
+ /**
188
+ * Optionally overrides the value of
189
+ * `--max-http-header-size` for requests received by this server, i.e.
190
+ * the maximum length of request headers in bytes.
191
+ * @default 16384
192
+ * @since v13.3.0
193
+ */
194
+ maxHeaderSize?: number | undefined;
195
+ /**
196
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
197
+ * @default true
198
+ * @since v16.5.0
199
+ */
200
+ noDelay?: boolean | undefined;
201
+ /**
202
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
203
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
204
+ * @default false
205
+ * @since v16.5.0
206
+ */
207
+ keepAlive?: boolean | undefined;
208
+ /**
209
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
210
+ * @default 0
211
+ * @since v16.5.0
212
+ */
213
+ keepAliveInitialDelay?: number | undefined;
214
+ /**
215
+ * A list of response headers that should be sent only once.
216
+ * If the header's value is an array, the items will be joined using `; `.
217
+ */
218
+ uniqueHeaders?: Array<string | string[]> | undefined;
219
+ }
220
+ type RequestListener<
221
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
222
+ Response extends typeof ServerResponse = typeof ServerResponse,
223
+ > = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
224
+ /**
225
+ * @since v0.1.17
226
+ */
227
+ class Server<
228
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
229
+ Response extends typeof ServerResponse = typeof ServerResponse,
230
+ > extends NetServer {
231
+ constructor(requestListener?: RequestListener<Request, Response>);
232
+ constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
233
+ /**
234
+ * Sets the timeout value for sockets, and emits a `'timeout'` event on
235
+ * the Server object, passing the socket as an argument, if a timeout
236
+ * occurs.
237
+ *
238
+ * If there is a `'timeout'` event listener on the Server object, then it
239
+ * will be called with the timed-out socket as an argument.
240
+ *
241
+ * By default, the Server does not timeout sockets. However, if a callback
242
+ * is assigned to the Server's `'timeout'` event, timeouts must be handled
243
+ * explicitly.
244
+ * @since v0.9.12
245
+ * @param [msecs=0 (no timeout)]
246
+ */
247
+ setTimeout(msecs?: number, callback?: () => void): this;
248
+ setTimeout(callback: () => void): this;
249
+ /**
250
+ * Limits maximum incoming headers count. If set to 0, no limit will be applied.
251
+ * @since v0.7.0
252
+ */
253
+ maxHeadersCount: number | null;
254
+ /**
255
+ * The maximum number of requests socket can handle
256
+ * before closing keep alive connection.
257
+ *
258
+ * A value of `0` will disable the limit.
259
+ *
260
+ * When the limit is reached it will set the `Connection` header value to `close`,
261
+ * but will not actually close the connection, subsequent requests sent
262
+ * after the limit is reached will get `503 Service Unavailable` as a response.
263
+ * @since v16.10.0
264
+ */
265
+ maxRequestsPerSocket: number | null;
266
+ /**
267
+ * The number of milliseconds of inactivity before a socket is presumed
268
+ * to have timed out.
269
+ *
270
+ * A value of `0` will disable the timeout behavior on incoming connections.
271
+ *
272
+ * The socket timeout logic is set up on connection, so changing this
273
+ * value only affects new connections to the server, not any existing connections.
274
+ * @since v0.9.12
275
+ */
276
+ timeout: number;
277
+ /**
278
+ * Limit the amount of time the parser will wait to receive the complete HTTP
279
+ * headers.
280
+ *
281
+ * If the timeout expires, the server responds with status 408 without
282
+ * forwarding the request to the request listener and then closes the connection.
283
+ *
284
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
285
+ * potential Denial-of-Service attacks in case the server is deployed without a
286
+ * reverse proxy in front.
287
+ * @since v11.3.0, v10.14.0
288
+ */
289
+ headersTimeout: number;
290
+ /**
291
+ * The number of milliseconds of inactivity a server needs to wait for additional
292
+ * incoming data, after it has finished writing the last response, before a socket
293
+ * will be destroyed. If the server receives new data before the keep-alive
294
+ * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
295
+ *
296
+ * A value of `0` will disable the keep-alive timeout behavior on incoming
297
+ * connections.
298
+ * A value of `0` makes the http server behave similarly to Node.js versions prior
299
+ * to 8.0.0, which did not have a keep-alive timeout.
300
+ *
301
+ * The socket timeout logic is set up on connection, so changing this value only
302
+ * affects new connections to the server, not any existing connections.
303
+ * @since v8.0.0
304
+ */
305
+ keepAliveTimeout: number;
306
+ /**
307
+ * Sets the timeout value in milliseconds for receiving the entire request from
308
+ * the client.
309
+ *
310
+ * If the timeout expires, the server responds with status 408 without
311
+ * forwarding the request to the request listener and then closes the connection.
312
+ *
313
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
314
+ * potential Denial-of-Service attacks in case the server is deployed without a
315
+ * reverse proxy in front.
316
+ * @since v14.11.0
317
+ */
318
+ requestTimeout: number;
319
+ /**
320
+ * Closes all connections connected to this server.
321
+ * @since v18.2.0
322
+ */
323
+ closeAllConnections(): void;
324
+ /**
325
+ * Closes all connections connected to this server which are not sending a request or waiting for a response.
326
+ * @since v18.2.0
327
+ */
328
+ closeIdleConnections(): void;
329
+ addListener(event: string, listener: (...args: any[]) => void): this;
330
+ addListener(event: 'close', listener: () => void): this;
331
+ addListener(event: 'connection', listener: (socket: Socket) => void): this;
332
+ addListener(event: 'error', listener: (err: Error) => void): this;
333
+ addListener(event: 'listening', listener: () => void): this;
334
+ addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
335
+ addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
336
+ addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
337
+ addListener(
338
+ event: 'connect',
339
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
340
+ ): this;
341
+ addListener(event: 'request', listener: RequestListener<Request, Response>): this;
342
+ addListener(
343
+ event: 'upgrade',
344
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
345
+ ): this;
346
+ emit(event: string, ...args: any[]): boolean;
347
+ emit(event: 'close'): boolean;
348
+ emit(event: 'connection', socket: Socket): boolean;
349
+ emit(event: 'error', err: Error): boolean;
350
+ emit(event: 'listening'): boolean;
351
+ emit(
352
+ event: 'checkContinue',
353
+ req: InstanceType<Request>,
354
+ res: InstanceType<Response> & { req: InstanceType<Request> },
355
+ ): boolean;
356
+ emit(
357
+ event: 'checkExpectation',
358
+ req: InstanceType<Request>,
359
+ res: InstanceType<Response> & { req: InstanceType<Request> },
360
+ ): boolean;
361
+ emit(event: 'clientError', err: Error, socket: stream.Duplex): boolean;
362
+ emit(event: 'connect', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
363
+ emit(
364
+ event: 'request',
365
+ req: InstanceType<Request>,
366
+ res: InstanceType<Response> & { req: InstanceType<Request> },
367
+ ): boolean;
368
+ emit(event: 'upgrade', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
369
+ on(event: string, listener: (...args: any[]) => void): this;
370
+ on(event: 'close', listener: () => void): this;
371
+ on(event: 'connection', listener: (socket: Socket) => void): this;
372
+ on(event: 'error', listener: (err: Error) => void): this;
373
+ on(event: 'listening', listener: () => void): this;
374
+ on(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
375
+ on(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
376
+ on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
377
+ on(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
378
+ on(event: 'request', listener: RequestListener<Request, Response>): this;
379
+ on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
380
+ once(event: string, listener: (...args: any[]) => void): this;
381
+ once(event: 'close', listener: () => void): this;
382
+ once(event: 'connection', listener: (socket: Socket) => void): this;
383
+ once(event: 'error', listener: (err: Error) => void): this;
384
+ once(event: 'listening', listener: () => void): this;
385
+ once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
386
+ once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
387
+ once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
388
+ once(
389
+ event: 'connect',
390
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
391
+ ): this;
392
+ once(event: 'request', listener: RequestListener<Request, Response>): this;
393
+ once(
394
+ event: 'upgrade',
395
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
396
+ ): this;
397
+ prependListener(event: string, listener: (...args: any[]) => void): this;
398
+ prependListener(event: 'close', listener: () => void): this;
399
+ prependListener(event: 'connection', listener: (socket: Socket) => void): this;
400
+ prependListener(event: 'error', listener: (err: Error) => void): this;
401
+ prependListener(event: 'listening', listener: () => void): this;
402
+ prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
403
+ prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
404
+ prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
405
+ prependListener(
406
+ event: 'connect',
407
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
408
+ ): this;
409
+ prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
410
+ prependListener(
411
+ event: 'upgrade',
412
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
413
+ ): this;
414
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
415
+ prependOnceListener(event: 'close', listener: () => void): this;
416
+ prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
417
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
418
+ prependOnceListener(event: 'listening', listener: () => void): this;
419
+ prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
420
+ prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
421
+ prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
422
+ prependOnceListener(
423
+ event: 'connect',
424
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
425
+ ): this;
426
+ prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
427
+ prependOnceListener(
428
+ event: 'upgrade',
429
+ listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
430
+ ): this;
431
+ }
432
+ /**
433
+ * This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from
434
+ * the perspective of the participants of HTTP transaction.
435
+ * @since v0.1.17
436
+ */
437
+ class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
438
+ readonly req: Request;
439
+ chunkedEncoding: boolean;
440
+ shouldKeepAlive: boolean;
441
+ useChunkedEncodingByDefault: boolean;
442
+ sendDate: boolean;
443
+ /**
444
+ * @deprecated Use `writableEnded` instead.
445
+ */
446
+ finished: boolean;
447
+ /**
448
+ * Read-only. `true` if the headers were sent, otherwise `false`.
449
+ * @since v0.9.3
450
+ */
451
+ readonly headersSent: boolean;
452
+ /**
453
+ * Aliases of `outgoingMessage.socket`
454
+ * @since v0.3.0
455
+ * @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
456
+ */
457
+ readonly connection: Socket | null;
458
+ /**
459
+ * Reference to the underlying socket. Usually, users will not want to access
460
+ * this property.
461
+ *
462
+ * After calling `outgoingMessage.end()`, this property will be nulled.
463
+ * @since v0.3.0
464
+ */
465
+ readonly socket: Socket | null;
466
+ constructor();
467
+ /**
468
+ * Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
469
+ * @since v0.9.12
470
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
471
+ */
472
+ setTimeout(msecs: number, callback?: () => void): this;
473
+ /**
474
+ * Sets a single header value for the header object.
475
+ * @since v0.4.0
476
+ * @param name Header name
477
+ * @param value Header value
478
+ */
479
+ setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
480
+ /**
481
+ * Gets the value of HTTP header with the given name. If such a name doesn't
482
+ * exist in message, it will be `undefined`.
483
+ * @since v0.4.0
484
+ * @param name Name of header
485
+ */
486
+ getHeader(name: string): number | string | string[] | undefined;
487
+ /**
488
+ * Returns a shallow copy of the current outgoing headers. Since a shallow
489
+ * copy is used, array values may be mutated without additional calls to
490
+ * various header-related HTTP module methods. The keys of the returned
491
+ * object are the header names and the values are the respective header
492
+ * values. All header names are lowercase.
493
+ *
494
+ * The object returned by the `outgoingMessage.getHeaders()` method does
495
+ * not prototypically inherit from the JavaScript Object. This means that
496
+ * typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`,
497
+ * and others are not defined and will not work.
498
+ *
499
+ * ```js
500
+ * outgoingMessage.setHeader('Foo', 'bar');
501
+ * outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
502
+ *
503
+ * const headers = outgoingMessage.getHeaders();
504
+ * // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
505
+ * ```
506
+ * @since v7.7.0
507
+ */
508
+ getHeaders(): OutgoingHttpHeaders;
509
+ /**
510
+ * Returns an array of names of headers of the outgoing outgoingMessage. All
511
+ * names are lowercase.
512
+ * @since v7.7.0
513
+ */
514
+ getHeaderNames(): string[];
515
+ /**
516
+ * Returns `true` if the header identified by `name` is currently set in the
517
+ * outgoing headers. The header name is case-insensitive.
518
+ *
519
+ * ```js
520
+ * const hasContentType = outgoingMessage.hasHeader('content-type');
521
+ * ```
522
+ * @since v7.7.0
523
+ */
524
+ hasHeader(name: string): boolean;
525
+ /**
526
+ * Removes a header that is queued for implicit sending.
527
+ *
528
+ * ```js
529
+ * outgoingMessage.removeHeader('Content-Encoding');
530
+ * ```
531
+ * @since v0.4.0
532
+ * @param name Header name
533
+ */
534
+ removeHeader(name: string): void;
535
+ /**
536
+ * Adds HTTP trailers (headers but at the end of the message) to the message.
537
+ *
538
+ * Trailers are **only** be emitted if the message is chunked encoded. If not,
539
+ * the trailer will be silently discarded.
540
+ *
541
+ * HTTP requires the `Trailer` header to be sent to emit trailers,
542
+ * with a list of header fields in its value, e.g.
543
+ *
544
+ * ```js
545
+ * message.writeHead(200, { 'Content-Type': 'text/plain',
546
+ * 'Trailer': 'Content-MD5' });
547
+ * message.write(fileData);
548
+ * message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
549
+ * message.end();
550
+ * ```
551
+ *
552
+ * Attempting to set a header field name or value that contains invalid characters
553
+ * will result in a `TypeError` being thrown.
554
+ * @since v0.3.0
555
+ */
556
+ addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
557
+ /**
558
+ * Compulsorily flushes the message headers
559
+ *
560
+ * For efficiency reason, Node.js normally buffers the message headers
561
+ * until `outgoingMessage.end()` is called or the first chunk of message data
562
+ * is written. It then tries to pack the headers and data into a single TCP
563
+ * packet.
564
+ *
565
+ * It is usually desired (it saves a TCP round-trip), but not when the first
566
+ * data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request.
567
+ * @since v1.6.0
568
+ */
569
+ flushHeaders(): void;
570
+ }
571
+ /**
572
+ * This object is created internally by an HTTP server, not by the user. It is
573
+ * passed as the second parameter to the `'request'` event.
574
+ * @since v0.1.17
575
+ */
576
+ class ServerResponse<Request extends IncomingMessage = IncomingMessage> extends OutgoingMessage<Request> {
577
+ /**
578
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
579
+ * this property controls the status code that will be sent to the client when
580
+ * the headers get flushed.
581
+ *
582
+ * ```js
583
+ * response.statusCode = 404;
584
+ * ```
585
+ *
586
+ * After response header was sent to the client, this property indicates the
587
+ * status code which was sent out.
588
+ * @since v0.4.0
589
+ */
590
+ statusCode: number;
591
+ /**
592
+ * When using implicit headers (not calling `response.writeHead()` explicitly),
593
+ * this property controls the status message that will be sent to the client when
594
+ * the headers get flushed. If this is left as `undefined` then the standard
595
+ * message for the status code will be used.
596
+ *
597
+ * ```js
598
+ * response.statusMessage = 'Not found';
599
+ * ```
600
+ *
601
+ * After response header was sent to the client, this property indicates the
602
+ * status message which was sent out.
603
+ * @since v0.11.8
604
+ */
605
+ statusMessage: string;
606
+ constructor(req: Request);
607
+ assignSocket(socket: Socket): void;
608
+ detachSocket(socket: Socket): void;
609
+ /**
610
+ * Sends an HTTP/1.1 100 Continue message to the client, indicating that
611
+ * the request body should be sent. See the `'checkContinue'` event on`Server`.
612
+ * @since v0.3.0
613
+ */
614
+ writeContinue(callback?: () => void): void;
615
+ /**
616
+ * Sends an HTTP/1.1 103 Early Hints message to the client with a Link header,
617
+ * indicating that the user agent can preload/preconnect the linked resources.
618
+ * The `hints` is an object containing the values of headers to be sent with
619
+ * early hints message. The optional `callback` argument will be called when
620
+ * the response message has been written.
621
+ *
622
+ * Example:
623
+ *
624
+ * ```js
625
+ * const earlyHintsLink = '</styles.css>; rel=preload; as=style';
626
+ * response.writeEarlyHints({
627
+ * 'link': earlyHintsLink,
628
+ * });
629
+ *
630
+ * const earlyHintsLinks = [
631
+ * '</styles.css>; rel=preload; as=style',
632
+ * '</scripts.js>; rel=preload; as=script',
633
+ * ];
634
+ * response.writeEarlyHints({
635
+ * 'link': earlyHintsLinks,
636
+ * 'x-trace-id': 'id for diagnostics'
637
+ * });
638
+ *
639
+ * const earlyHintsCallback = () => console.log('early hints message sent');
640
+ * response.writeEarlyHints({
641
+ * 'link': earlyHintsLinks
642
+ * }, earlyHintsCallback);
643
+ * ```
644
+ *
645
+ * @since v18.11.0
646
+ * @param hints An object containing the values of headers
647
+ * @param callback Will be called when the response message has been written
648
+ */
649
+ writeEarlyHints(hints: Record<string, string | string[]>, callback?: () => void): void;
650
+ /**
651
+ * Sends a response header to the request. The status code is a 3-digit HTTP
652
+ * status code, like `404`. The last argument, `headers`, are the response headers.
653
+ * Optionally one can give a human-readable `statusMessage` as the second
654
+ * argument.
655
+ *
656
+ * `headers` may be an `Array` where the keys and values are in the same list.
657
+ * It is _not_ a list of tuples. So, the even-numbered offsets are key values,
658
+ * and the odd-numbered offsets are the associated values. The array is in the same
659
+ * format as `request.rawHeaders`.
660
+ *
661
+ * Returns a reference to the `ServerResponse`, so that calls can be chained.
662
+ *
663
+ * ```js
664
+ * const body = 'hello world';
665
+ * response
666
+ * .writeHead(200, {
667
+ * 'Content-Length': Buffer.byteLength(body),
668
+ * 'Content-Type': 'text/plain'
669
+ * })
670
+ * .end(body);
671
+ * ```
672
+ *
673
+ * This method must only be called once on a message and it must
674
+ * be called before `response.end()` is called.
675
+ *
676
+ * If `response.write()` or `response.end()` are called before calling
677
+ * this, the implicit/mutable headers will be calculated and call this function.
678
+ *
679
+ * When headers have been set with `response.setHeader()`, they will be merged
680
+ * with any headers passed to `response.writeHead()`, with the headers passed
681
+ * to `response.writeHead()` given precedence.
682
+ *
683
+ * If this method is called and `response.setHeader()` has not been called,
684
+ * it will directly write the supplied header values onto the network channel
685
+ * without caching internally, and the `response.getHeader()` on the header
686
+ * will not yield the expected result. If progressive population of headers is
687
+ * desired with potential future retrieval and modification, use `response.setHeader()` instead.
688
+ *
689
+ * ```js
690
+ * // Returns content-type = text/plain
691
+ * const server = http.createServer((req, res) => {
692
+ * res.setHeader('Content-Type', 'text/html');
693
+ * res.setHeader('X-Foo', 'bar');
694
+ * res.writeHead(200, { 'Content-Type': 'text/plain' });
695
+ * res.end('ok');
696
+ * });
697
+ * ```
698
+ *
699
+ * `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
700
+ * does not check whether `Content-Length` and the length of the body which has
701
+ * been transmitted are equal or not.
702
+ *
703
+ * Attempting to set a header field name or value that contains invalid characters
704
+ * will result in a `TypeError` being thrown.
705
+ * @since v0.1.30
706
+ */
707
+ writeHead(
708
+ statusCode: number,
709
+ statusMessage?: string,
710
+ headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
711
+ ): this;
712
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
713
+ /**
714
+ * Sends an HTTP/1.1 102 Processing message to the client, indicating that
715
+ * the request body should be sent.
716
+ * @since v10.0.0
717
+ */
718
+ writeProcessing(): void;
719
+ }
720
+ interface InformationEvent {
721
+ statusCode: number;
722
+ statusMessage: string;
723
+ httpVersion: string;
724
+ httpVersionMajor: number;
725
+ httpVersionMinor: number;
726
+ headers: IncomingHttpHeaders;
727
+ rawHeaders: string[];
728
+ }
729
+ /**
730
+ * This object is created internally and returned from {@link request}. It
731
+ * represents an _in-progress_ request whose header has already been queued. The
732
+ * header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will
733
+ * be sent along with the first data chunk or when calling `request.end()`.
734
+ *
735
+ * To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response
736
+ * headers have been received. The `'response'` event is executed with one
737
+ * argument which is an instance of {@link IncomingMessage}.
738
+ *
739
+ * During the `'response'` event, one can add listeners to the
740
+ * response object; particularly to listen for the `'data'` event.
741
+ *
742
+ * If no `'response'` handler is added, then the response will be
743
+ * entirely discarded. However, if a `'response'` event handler is added,
744
+ * then the data from the response object **must** be consumed, either by
745
+ * calling `response.read()` whenever there is a `'readable'` event, or
746
+ * by adding a `'data'` handler, or by calling the `.resume()` method.
747
+ * Until the data is consumed, the `'end'` event will not fire. Also, until
748
+ * the data is read it will consume memory that can eventually lead to a
749
+ * 'process out of memory' error.
750
+ *
751
+ * For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
752
+ *
753
+ * Node.js does not check whether Content-Length and the length of the
754
+ * body which has been transmitted are equal or not.
755
+ * @since v0.1.17
756
+ */
757
+ class ClientRequest extends OutgoingMessage {
758
+ /**
759
+ * The `request.aborted` property will be `true` if the request has
760
+ * been aborted.
761
+ * @since v0.11.14
762
+ * @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
763
+ */
764
+ aborted: boolean;
765
+ /**
766
+ * The request host.
767
+ * @since v14.5.0, v12.19.0
768
+ */
769
+ host: string;
770
+ /**
771
+ * The request protocol.
772
+ * @since v14.5.0, v12.19.0
773
+ */
774
+ protocol: string;
775
+ /**
776
+ * When sending request through a keep-alive enabled agent, the underlying socket
777
+ * might be reused. But if server closes connection at unfortunate time, client
778
+ * may run into a 'ECONNRESET' error.
779
+ *
780
+ * ```js
781
+ * const http = require('http');
782
+ *
783
+ * // Server has a 5 seconds keep-alive timeout by default
784
+ * http
785
+ * .createServer((req, res) => {
786
+ * res.write('hello\n');
787
+ * res.end();
788
+ * })
789
+ * .listen(3000);
790
+ *
791
+ * setInterval(() => {
792
+ * // Adapting a keep-alive agent
793
+ * http.get('http://localhost:3000', { agent }, (res) => {
794
+ * res.on('data', (data) => {
795
+ * // Do nothing
796
+ * });
797
+ * });
798
+ * }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
799
+ * ```
800
+ *
801
+ * By marking a request whether it reused socket or not, we can do
802
+ * automatic error retry base on it.
803
+ *
804
+ * ```js
805
+ * const http = require('http');
806
+ * const agent = new http.Agent({ keepAlive: true });
807
+ *
808
+ * function retriableRequest() {
809
+ * const req = http
810
+ * .get('http://localhost:3000', { agent }, (res) => {
811
+ * // ...
812
+ * })
813
+ * .on('error', (err) => {
814
+ * // Check if retry is needed
815
+ * if (req.reusedSocket &#x26;&#x26; err.code === 'ECONNRESET') {
816
+ * retriableRequest();
817
+ * }
818
+ * });
819
+ * }
820
+ *
821
+ * retriableRequest();
822
+ * ```
823
+ * @since v13.0.0, v12.16.0
824
+ */
825
+ reusedSocket: boolean;
826
+ /**
827
+ * Limits maximum response headers count. If set to 0, no limit will be applied.
828
+ */
829
+ maxHeadersCount: number;
830
+ constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
831
+ /**
832
+ * The request method.
833
+ * @since v0.1.97
834
+ */
835
+ method: string;
836
+ /**
837
+ * The request path.
838
+ * @since v0.4.0
839
+ */
840
+ path: string;
841
+ /**
842
+ * Marks the request as aborting. Calling this will cause remaining data
843
+ * in the response to be dropped and the socket to be destroyed.
844
+ * @since v0.3.8
845
+ * @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead.
846
+ */
847
+ abort(): void;
848
+ onSocket(socket: Socket): void;
849
+ /**
850
+ * Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called.
851
+ * @since v0.5.9
852
+ * @param timeout Milliseconds before a request times out.
853
+ * @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event.
854
+ */
855
+ setTimeout(timeout: number, callback?: () => void): this;
856
+ /**
857
+ * Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called.
858
+ * @since v0.5.9
859
+ */
860
+ setNoDelay(noDelay?: boolean): void;
861
+ /**
862
+ * Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called.
863
+ * @since v0.5.9
864
+ */
865
+ setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
866
+ /**
867
+ * Returns an array containing the unique names of the current outgoing raw
868
+ * headers. Header names are returned with their exact casing being set.
869
+ *
870
+ * ```js
871
+ * request.setHeader('Foo', 'bar');
872
+ * request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
873
+ *
874
+ * const headerNames = request.getRawHeaderNames();
875
+ * // headerNames === ['Foo', 'Set-Cookie']
876
+ * ```
877
+ * @since v15.13.0, v14.17.0
878
+ */
879
+ getRawHeaderNames(): string[];
880
+ /**
881
+ * @deprecated
882
+ */
883
+ addListener(event: 'abort', listener: () => void): this;
884
+ addListener(
885
+ event: 'connect',
886
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
887
+ ): this;
888
+ addListener(event: 'continue', listener: () => void): this;
889
+ addListener(event: 'information', listener: (info: InformationEvent) => void): this;
890
+ addListener(event: 'response', listener: (response: IncomingMessage) => void): this;
891
+ addListener(event: 'socket', listener: (socket: Socket) => void): this;
892
+ addListener(event: 'timeout', listener: () => void): this;
893
+ addListener(
894
+ event: 'upgrade',
895
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
896
+ ): this;
897
+ addListener(event: 'close', listener: () => void): this;
898
+ addListener(event: 'drain', listener: () => void): this;
899
+ addListener(event: 'error', listener: (err: Error) => void): this;
900
+ addListener(event: 'finish', listener: () => void): this;
901
+ addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
902
+ addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
903
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
904
+ /**
905
+ * @deprecated
906
+ */
907
+ on(event: 'abort', listener: () => void): this;
908
+ on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
909
+ on(event: 'continue', listener: () => void): this;
910
+ on(event: 'information', listener: (info: InformationEvent) => void): this;
911
+ on(event: 'response', listener: (response: IncomingMessage) => void): this;
912
+ on(event: 'socket', listener: (socket: Socket) => void): this;
913
+ on(event: 'timeout', listener: () => void): this;
914
+ on(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
915
+ on(event: 'close', listener: () => void): this;
916
+ on(event: 'drain', listener: () => void): this;
917
+ on(event: 'error', listener: (err: Error) => void): this;
918
+ on(event: 'finish', listener: () => void): this;
919
+ on(event: 'pipe', listener: (src: stream.Readable) => void): this;
920
+ on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
921
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
922
+ /**
923
+ * @deprecated
924
+ */
925
+ once(event: 'abort', listener: () => void): this;
926
+ once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
927
+ once(event: 'continue', listener: () => void): this;
928
+ once(event: 'information', listener: (info: InformationEvent) => void): this;
929
+ once(event: 'response', listener: (response: IncomingMessage) => void): this;
930
+ once(event: 'socket', listener: (socket: Socket) => void): this;
931
+ once(event: 'timeout', listener: () => void): this;
932
+ once(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
933
+ once(event: 'close', listener: () => void): this;
934
+ once(event: 'drain', listener: () => void): this;
935
+ once(event: 'error', listener: (err: Error) => void): this;
936
+ once(event: 'finish', listener: () => void): this;
937
+ once(event: 'pipe', listener: (src: stream.Readable) => void): this;
938
+ once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
939
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
940
+ /**
941
+ * @deprecated
942
+ */
943
+ prependListener(event: 'abort', listener: () => void): this;
944
+ prependListener(
945
+ event: 'connect',
946
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
947
+ ): this;
948
+ prependListener(event: 'continue', listener: () => void): this;
949
+ prependListener(event: 'information', listener: (info: InformationEvent) => void): this;
950
+ prependListener(event: 'response', listener: (response: IncomingMessage) => void): this;
951
+ prependListener(event: 'socket', listener: (socket: Socket) => void): this;
952
+ prependListener(event: 'timeout', listener: () => void): this;
953
+ prependListener(
954
+ event: 'upgrade',
955
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
956
+ ): this;
957
+ prependListener(event: 'close', listener: () => void): this;
958
+ prependListener(event: 'drain', listener: () => void): this;
959
+ prependListener(event: 'error', listener: (err: Error) => void): this;
960
+ prependListener(event: 'finish', listener: () => void): this;
961
+ prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
962
+ prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
963
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
964
+ /**
965
+ * @deprecated
966
+ */
967
+ prependOnceListener(event: 'abort', listener: () => void): this;
968
+ prependOnceListener(
969
+ event: 'connect',
970
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
971
+ ): this;
972
+ prependOnceListener(event: 'continue', listener: () => void): this;
973
+ prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this;
974
+ prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this;
975
+ prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this;
976
+ prependOnceListener(event: 'timeout', listener: () => void): this;
977
+ prependOnceListener(
978
+ event: 'upgrade',
979
+ listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
980
+ ): this;
981
+ prependOnceListener(event: 'close', listener: () => void): this;
982
+ prependOnceListener(event: 'drain', listener: () => void): this;
983
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
984
+ prependOnceListener(event: 'finish', listener: () => void): this;
985
+ prependOnceListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
986
+ prependOnceListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
987
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
988
+ }
989
+ /**
990
+ * An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
991
+ * access response
992
+ * status, headers and data.
993
+ *
994
+ * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
995
+ * parse and emit the incoming HTTP headers and payload, as the underlying socket
996
+ * may be reused multiple times in case of keep-alive.
997
+ * @since v0.1.17
998
+ */
999
+ class IncomingMessage extends stream.Readable {
1000
+ constructor(socket: Socket);
1001
+ /**
1002
+ * The `message.aborted` property will be `true` if the request has
1003
+ * been aborted.
1004
+ * @since v10.1.0
1005
+ * @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
1006
+ */
1007
+ aborted: boolean;
1008
+ /**
1009
+ * In case of server request, the HTTP version sent by the client. In the case of
1010
+ * client response, the HTTP version of the connected-to server.
1011
+ * Probably either `'1.1'` or `'1.0'`.
1012
+ *
1013
+ * Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
1014
+ * @since v0.1.1
1015
+ */
1016
+ httpVersion: string;
1017
+ httpVersionMajor: number;
1018
+ httpVersionMinor: number;
1019
+ /**
1020
+ * The `message.complete` property will be `true` if a complete HTTP message has
1021
+ * been received and successfully parsed.
1022
+ *
1023
+ * This property is particularly useful as a means of determining if a client or
1024
+ * server fully transmitted a message before a connection was terminated:
1025
+ *
1026
+ * ```js
1027
+ * const req = http.request({
1028
+ * host: '127.0.0.1',
1029
+ * port: 8080,
1030
+ * method: 'POST'
1031
+ * }, (res) => {
1032
+ * res.resume();
1033
+ * res.on('end', () => {
1034
+ * if (!res.complete)
1035
+ * console.error(
1036
+ * 'The connection was terminated while the message was still being sent');
1037
+ * });
1038
+ * });
1039
+ * ```
1040
+ * @since v0.3.0
1041
+ */
1042
+ complete: boolean;
1043
+ /**
1044
+ * Alias for `message.socket`.
1045
+ * @since v0.1.90
1046
+ * @deprecated Since v16.0.0 - Use `socket`.
1047
+ */
1048
+ connection: Socket;
1049
+ /**
1050
+ * The `net.Socket` object associated with the connection.
1051
+ *
1052
+ * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the
1053
+ * client's authentication details.
1054
+ *
1055
+ * This property is guaranteed to be an instance of the `net.Socket` class,
1056
+ * a subclass of `stream.Duplex`, unless the user specified a socket
1057
+ * type other than `net.Socket` or internally nulled.
1058
+ * @since v0.3.0
1059
+ */
1060
+ socket: Socket;
1061
+ /**
1062
+ * The request/response headers object.
1063
+ *
1064
+ * Key-value pairs of header names and values. Header names are lower-cased.
1065
+ *
1066
+ * ```js
1067
+ * // Prints something like:
1068
+ * //
1069
+ * // { 'user-agent': 'curl/7.22.0',
1070
+ * // host: '127.0.0.1:8000',
1071
+ * // accept: '*' }
1072
+ * console.log(request.getHeaders());
1073
+ * ```
1074
+ *
1075
+ * Duplicates in raw headers are handled in the following ways, depending on the
1076
+ * header name:
1077
+ *
1078
+ * * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
1079
+ * `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
1080
+ * * `set-cookie` is always an array. Duplicates are added to the array.
1081
+ * * For duplicate `cookie` headers, the values are joined together with '; '.
1082
+ * * For all other headers, the values are joined together with ', '.
1083
+ * @since v0.1.5
1084
+ */
1085
+ headers: IncomingHttpHeaders;
1086
+ /**
1087
+ * The raw request/response headers list exactly as they were received.
1088
+ *
1089
+ * The keys and values are in the same list. It is _not_ a
1090
+ * list of tuples. So, the even-numbered offsets are key values, and the
1091
+ * odd-numbered offsets are the associated values.
1092
+ *
1093
+ * Header names are not lowercased, and duplicates are not merged.
1094
+ *
1095
+ * ```js
1096
+ * // Prints something like:
1097
+ * //
1098
+ * // [ 'user-agent',
1099
+ * // 'this is invalid because there can be only one',
1100
+ * // 'User-Agent',
1101
+ * // 'curl/7.22.0',
1102
+ * // 'Host',
1103
+ * // '127.0.0.1:8000',
1104
+ * // 'ACCEPT',
1105
+ * // '*' ]
1106
+ * console.log(request.rawHeaders);
1107
+ * ```
1108
+ * @since v0.11.6
1109
+ */
1110
+ rawHeaders: string[];
1111
+ /**
1112
+ * The request/response trailers object. Only populated at the `'end'` event.
1113
+ * @since v0.3.0
1114
+ */
1115
+ trailers: NodeJS.Dict<string>;
1116
+ /**
1117
+ * The raw request/response trailer keys and values exactly as they were
1118
+ * received. Only populated at the `'end'` event.
1119
+ * @since v0.11.6
1120
+ */
1121
+ rawTrailers: string[];
1122
+ /**
1123
+ * Calls `message.socket.setTimeout(msecs, callback)`.
1124
+ * @since v0.5.9
1125
+ */
1126
+ setTimeout(msecs: number, callback?: () => void): this;
1127
+ /**
1128
+ * **Only valid for request obtained from {@link Server}.**
1129
+ *
1130
+ * The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`.
1131
+ * @since v0.1.1
1132
+ */
1133
+ method?: string | undefined;
1134
+ /**
1135
+ * **Only valid for request obtained from {@link Server}.**
1136
+ *
1137
+ * Request URL string. This contains only the URL that is present in the actual
1138
+ * HTTP request. Take the following request:
1139
+ *
1140
+ * ```http
1141
+ * GET /status?name=ryan HTTP/1.1
1142
+ * Accept: text/plain
1143
+ * ```
1144
+ *
1145
+ * To parse the URL into its parts:
1146
+ *
1147
+ * ```js
1148
+ * new URL(request.url, `http://${request.getHeaders().host}`);
1149
+ * ```
1150
+ *
1151
+ * When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
1152
+ *
1153
+ * ```console
1154
+ * $ node
1155
+ * > new URL(request.url, `http://${request.getHeaders().host}`)
1156
+ * URL {
1157
+ * href: 'http://localhost:3000/status?name=ryan',
1158
+ * origin: 'http://localhost:3000',
1159
+ * protocol: 'http:',
1160
+ * username: '',
1161
+ * password: '',
1162
+ * host: 'localhost:3000',
1163
+ * hostname: 'localhost',
1164
+ * port: '3000',
1165
+ * pathname: '/status',
1166
+ * search: '?name=ryan',
1167
+ * searchParams: URLSearchParams { 'name' => 'ryan' },
1168
+ * hash: ''
1169
+ * }
1170
+ * ```
1171
+ * @since v0.1.90
1172
+ */
1173
+ url?: string | undefined;
1174
+ /**
1175
+ * **Only valid for response obtained from {@link ClientRequest}.**
1176
+ *
1177
+ * The 3-digit HTTP response status code. E.G. `404`.
1178
+ * @since v0.1.1
1179
+ */
1180
+ statusCode?: number | undefined;
1181
+ /**
1182
+ * **Only valid for response obtained from {@link ClientRequest}.**
1183
+ *
1184
+ * The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`.
1185
+ * @since v0.11.10
1186
+ */
1187
+ statusMessage?: string | undefined;
1188
+ /**
1189
+ * Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed
1190
+ * as an argument to any listeners on the event.
1191
+ * @since v0.3.0
1192
+ */
1193
+ destroy(error?: Error): this;
1194
+ }
1195
+ interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1196
+ /**
1197
+ * Keep sockets around in a pool to be used by other requests in the future. Default = false
1198
+ */
1199
+ keepAlive?: boolean | undefined;
1200
+ /**
1201
+ * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
1202
+ * Only relevant if keepAlive is set to true.
1203
+ */
1204
+ keepAliveMsecs?: number | undefined;
1205
+ /**
1206
+ * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1207
+ */
1208
+ maxSockets?: number | undefined;
1209
+ /**
1210
+ * Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
1211
+ */
1212
+ maxTotalSockets?: number | undefined;
1213
+ /**
1214
+ * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
1215
+ */
1216
+ maxFreeSockets?: number | undefined;
1217
+ /**
1218
+ * Socket timeout in milliseconds. This will set the timeout after the socket is connected.
1219
+ */
1220
+ timeout?: number | undefined;
1221
+ /**
1222
+ * Scheduling strategy to apply when picking the next free socket to use.
1223
+ * @default `lifo`
1224
+ */
1225
+ scheduling?: 'fifo' | 'lifo' | undefined;
1226
+ }
1227
+ /**
1228
+ * An `Agent` is responsible for managing connection persistence
1229
+ * and reuse for HTTP clients. It maintains a queue of pending requests
1230
+ * for a given host and port, reusing a single socket connection for each
1231
+ * until the queue is empty, at which time the socket is either destroyed
1232
+ * or put into a pool where it is kept to be used again for requests to the
1233
+ * same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`.
1234
+ *
1235
+ * Pooled connections have TCP Keep-Alive enabled for them, but servers may
1236
+ * still close idle connections, in which case they will be removed from the
1237
+ * pool and a new connection will be made when a new HTTP request is made for
1238
+ * that host and port. Servers may also refuse to allow multiple requests
1239
+ * over the same connection, in which case the connection will have to be
1240
+ * remade for every request and cannot be pooled. The `Agent` will still make
1241
+ * the requests to that server, but each one will occur over a new connection.
1242
+ *
1243
+ * When a connection is closed by the client or the server, it is removed
1244
+ * from the pool. Any unused sockets in the pool will be unrefed so as not
1245
+ * to keep the Node.js process running when there are no outstanding requests.
1246
+ * (see `socket.unref()`).
1247
+ *
1248
+ * It is good practice, to `destroy()` an `Agent` instance when it is no
1249
+ * longer in use, because unused sockets consume OS resources.
1250
+ *
1251
+ * Sockets are removed from an agent when the socket emits either
1252
+ * a `'close'` event or an `'agentRemove'` event. When intending to keep one
1253
+ * HTTP request open for a long time without keeping it in the agent, something
1254
+ * like the following may be done:
1255
+ *
1256
+ * ```js
1257
+ * http.get(options, (res) => {
1258
+ * // Do stuff
1259
+ * }).on('socket', (socket) => {
1260
+ * socket.emit('agentRemove');
1261
+ * });
1262
+ * ```
1263
+ *
1264
+ * An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options
1265
+ * will be used
1266
+ * for the client connection.
1267
+ *
1268
+ * `agent:false`:
1269
+ *
1270
+ * ```js
1271
+ * http.get({
1272
+ * hostname: 'localhost',
1273
+ * port: 80,
1274
+ * path: '/',
1275
+ * agent: false // Create a new agent just for this one request
1276
+ * }, (res) => {
1277
+ * // Do stuff with response
1278
+ * });
1279
+ * ```
1280
+ * @since v0.3.4
1281
+ */
1282
+ class Agent {
1283
+ /**
1284
+ * By default set to 256\. For agents with `keepAlive` enabled, this
1285
+ * sets the maximum number of sockets that will be left open in the free
1286
+ * state.
1287
+ * @since v0.11.7
1288
+ */
1289
+ maxFreeSockets: number;
1290
+ /**
1291
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1292
+ * can have open per origin. Origin is the returned value of `agent.getName()`.
1293
+ * @since v0.3.6
1294
+ */
1295
+ maxSockets: number;
1296
+ /**
1297
+ * By default set to `Infinity`. Determines how many concurrent sockets the agent
1298
+ * can have open. Unlike `maxSockets`, this parameter applies across all origins.
1299
+ * @since v14.5.0, v12.19.0
1300
+ */
1301
+ maxTotalSockets: number;
1302
+ /**
1303
+ * An object which contains arrays of sockets currently awaiting use by
1304
+ * the agent when `keepAlive` is enabled. Do not modify.
1305
+ *
1306
+ * Sockets in the `freeSockets` list will be automatically destroyed and
1307
+ * removed from the array on `'timeout'`.
1308
+ * @since v0.11.4
1309
+ */
1310
+ readonly freeSockets: NodeJS.ReadOnlyDict<Socket[]>;
1311
+ /**
1312
+ * An object which contains arrays of sockets currently in use by the
1313
+ * agent. Do not modify.
1314
+ * @since v0.3.6
1315
+ */
1316
+ readonly sockets: NodeJS.ReadOnlyDict<Socket[]>;
1317
+ /**
1318
+ * An object which contains queues of requests that have not yet been assigned to
1319
+ * sockets. Do not modify.
1320
+ * @since v0.5.9
1321
+ */
1322
+ readonly requests: NodeJS.ReadOnlyDict<IncomingMessage[]>;
1323
+ constructor(opts?: AgentOptions);
1324
+ /**
1325
+ * Destroy any sockets that are currently in use by the agent.
1326
+ *
1327
+ * It is usually not necessary to do this. However, if using an
1328
+ * agent with `keepAlive` enabled, then it is best to explicitly shut down
1329
+ * the agent when it is no longer needed. Otherwise,
1330
+ * sockets might stay open for quite a long time before the server
1331
+ * terminates them.
1332
+ * @since v0.11.4
1333
+ */
1334
+ destroy(): void;
1335
+ }
1336
+ const METHODS: string[];
1337
+ const STATUS_CODES: {
1338
+ [errorCode: number]: string | undefined;
1339
+ [errorCode: string]: string | undefined;
1340
+ };
1341
+ /**
1342
+ * Returns a new instance of {@link Server}.
1343
+ *
1344
+ * The `requestListener` is a function which is automatically
1345
+ * added to the `'request'` event.
1346
+ * @since v0.1.13
1347
+ */
1348
+ function createServer<
1349
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1350
+ Response extends typeof ServerResponse = typeof ServerResponse,
1351
+ >(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
1352
+ function createServer<
1353
+ Request extends typeof IncomingMessage = typeof IncomingMessage,
1354
+ Response extends typeof ServerResponse = typeof ServerResponse,
1355
+ >(
1356
+ options: ServerOptions<Request, Response>,
1357
+ requestListener?: RequestListener<Request, Response>,
1358
+ ): Server<Request, Response>;
1359
+ // although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
1360
+ // create interface RequestOptions would make the naming more clear to developers
1361
+ interface RequestOptions extends ClientRequestArgs {}
1362
+ /**
1363
+ * `options` in `socket.connect()` are also supported.
1364
+ *
1365
+ * Node.js maintains several connections per server to make HTTP requests.
1366
+ * This function allows one to transparently issue requests.
1367
+ *
1368
+ * `url` can be a string or a `URL` object. If `url` is a
1369
+ * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
1370
+ *
1371
+ * If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence.
1372
+ *
1373
+ * The optional `callback` parameter will be added as a one-time listener for
1374
+ * the `'response'` event.
1375
+ *
1376
+ * `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to
1377
+ * upload a file with a POST request, then write to the `ClientRequest` object.
1378
+ *
1379
+ * ```js
1380
+ * const http = require('http');
1381
+ *
1382
+ * const postData = JSON.stringify({
1383
+ * 'msg': 'Hello World!'
1384
+ * });
1385
+ *
1386
+ * const options = {
1387
+ * hostname: 'www.google.com',
1388
+ * port: 80,
1389
+ * path: '/upload',
1390
+ * method: 'POST',
1391
+ * headers: {
1392
+ * 'Content-Type': 'application/json',
1393
+ * 'Content-Length': Buffer.byteLength(postData)
1394
+ * }
1395
+ * };
1396
+ *
1397
+ * const req = http.request(options, (res) => {
1398
+ * console.log(`STATUS: ${res.statusCode}`);
1399
+ * console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
1400
+ * res.setEncoding('utf8');
1401
+ * res.on('data', (chunk) => {
1402
+ * console.log(`BODY: ${chunk}`);
1403
+ * });
1404
+ * res.on('end', () => {
1405
+ * console.log('No more data in response.');
1406
+ * });
1407
+ * });
1408
+ *
1409
+ * req.on('error', (e) => {
1410
+ * console.error(`problem with request: ${e.message}`);
1411
+ * });
1412
+ *
1413
+ * // Write data to request body
1414
+ * req.write(postData);
1415
+ * req.end();
1416
+ * ```
1417
+ *
1418
+ * In the example `req.end()` was called. With `http.request()` one
1419
+ * must always call `req.end()` to signify the end of the request -
1420
+ * even if there is no data being written to the request body.
1421
+ *
1422
+ * If any error is encountered during the request (be that with DNS resolution,
1423
+ * TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted
1424
+ * on the returned request object. As with all `'error'` events, if no listeners
1425
+ * are registered the error will be thrown.
1426
+ *
1427
+ * There are a few special headers that should be noted.
1428
+ *
1429
+ * * Sending a 'Connection: keep-alive' will notify Node.js that the connection to
1430
+ * the server should be persisted until the next request.
1431
+ * * Sending a 'Content-Length' header will disable the default chunked encoding.
1432
+ * * Sending an 'Expect' header will immediately send the request headers.
1433
+ * Usually, when sending 'Expect: 100-continue', both a timeout and a listener
1434
+ * for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more
1435
+ * information.
1436
+ * * Sending an Authorization header will override using the `auth` option
1437
+ * to compute basic authentication.
1438
+ *
1439
+ * Example using a `URL` as `options`:
1440
+ *
1441
+ * ```js
1442
+ * const options = new URL('http://abc:[email protected]');
1443
+ *
1444
+ * const req = http.request(options, (res) => {
1445
+ * // ...
1446
+ * });
1447
+ * ```
1448
+ *
1449
+ * In a successful request, the following events will be emitted in the following
1450
+ * order:
1451
+ *
1452
+ * * `'socket'`
1453
+ * * `'response'`
1454
+ * * `'data'` any number of times, on the `res` object
1455
+ * (`'data'` will not be emitted at all if the response body is empty, for
1456
+ * instance, in most redirects)
1457
+ * * `'end'` on the `res` object
1458
+ * * `'close'`
1459
+ *
1460
+ * In the case of a connection error, the following events will be emitted:
1461
+ *
1462
+ * * `'socket'`
1463
+ * * `'error'`
1464
+ * * `'close'`
1465
+ *
1466
+ * In the case of a premature connection close before the response is received,
1467
+ * the following events will be emitted in the following order:
1468
+ *
1469
+ * * `'socket'`
1470
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1471
+ * * `'close'`
1472
+ *
1473
+ * In the case of a premature connection close after the response is received,
1474
+ * the following events will be emitted in the following order:
1475
+ *
1476
+ * * `'socket'`
1477
+ * * `'response'`
1478
+ * * `'data'` any number of times, on the `res` object
1479
+ * * (connection closed here)
1480
+ * * `'aborted'` on the `res` object
1481
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1482
+ * * `'close'`
1483
+ * * `'close'` on the `res` object
1484
+ *
1485
+ * If `req.destroy()` is called before a socket is assigned, the following
1486
+ * events will be emitted in the following order:
1487
+ *
1488
+ * * (`req.destroy()` called here)
1489
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1490
+ * * `'close'`
1491
+ *
1492
+ * If `req.destroy()` is called before the connection succeeds, the following
1493
+ * events will be emitted in the following order:
1494
+ *
1495
+ * * `'socket'`
1496
+ * * (`req.destroy()` called here)
1497
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1498
+ * * `'close'`
1499
+ *
1500
+ * If `req.destroy()` is called after the response is received, the following
1501
+ * events will be emitted in the following order:
1502
+ *
1503
+ * * `'socket'`
1504
+ * * `'response'`
1505
+ * * `'data'` any number of times, on the `res` object
1506
+ * * (`req.destroy()` called here)
1507
+ * * `'aborted'` on the `res` object
1508
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1509
+ * * `'close'`
1510
+ * * `'close'` on the `res` object
1511
+ *
1512
+ * If `req.abort()` is called before a socket is assigned, the following
1513
+ * events will be emitted in the following order:
1514
+ *
1515
+ * * (`req.abort()` called here)
1516
+ * * `'abort'`
1517
+ * * `'close'`
1518
+ *
1519
+ * If `req.abort()` is called before the connection succeeds, the following
1520
+ * events will be emitted in the following order:
1521
+ *
1522
+ * * `'socket'`
1523
+ * * (`req.abort()` called here)
1524
+ * * `'abort'`
1525
+ * * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
1526
+ * * `'close'`
1527
+ *
1528
+ * If `req.abort()` is called after the response is received, the following
1529
+ * events will be emitted in the following order:
1530
+ *
1531
+ * * `'socket'`
1532
+ * * `'response'`
1533
+ * * `'data'` any number of times, on the `res` object
1534
+ * * (`req.abort()` called here)
1535
+ * * `'abort'`
1536
+ * * `'aborted'` on the `res` object
1537
+ * * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
1538
+ * * `'close'`
1539
+ * * `'close'` on the `res` object
1540
+ *
1541
+ * Setting the `timeout` option or using the `setTimeout()` function will
1542
+ * not abort the request or do anything besides add a `'timeout'` event.
1543
+ *
1544
+ * Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
1545
+ * request itself.
1546
+ * @since v0.3.6
1547
+ */
1548
+ function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1549
+ function request(
1550
+ url: string | URL,
1551
+ options: RequestOptions,
1552
+ callback?: (res: IncomingMessage) => void,
1553
+ ): ClientRequest;
1554
+ /**
1555
+ * Since most requests are GET requests without bodies, Node.js provides this
1556
+ * convenience method. The only difference between this method and {@link request} is that it sets the method to GET and calls `req.end()`automatically. The callback must take care to consume the
1557
+ * response
1558
+ * data for reasons stated in {@link ClientRequest} section.
1559
+ *
1560
+ * The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}.
1561
+ *
1562
+ * JSON fetching example:
1563
+ *
1564
+ * ```js
1565
+ * http.get('http://localhost:8000/', (res) => {
1566
+ * const { statusCode } = res;
1567
+ * const contentType = res.headers['content-type'];
1568
+ *
1569
+ * let error;
1570
+ * // Any 2xx status code signals a successful response but
1571
+ * // here we're only checking for 200.
1572
+ * if (statusCode !== 200) {
1573
+ * error = new Error('Request Failed.\n' +
1574
+ * `Status Code: ${statusCode}`);
1575
+ * } else if (!/^application\/json/.test(contentType)) {
1576
+ * error = new Error('Invalid content-type.\n' +
1577
+ * `Expected application/json but received ${contentType}`);
1578
+ * }
1579
+ * if (error) {
1580
+ * console.error(error.message);
1581
+ * // Consume response data to free up memory
1582
+ * res.resume();
1583
+ * return;
1584
+ * }
1585
+ *
1586
+ * res.setEncoding('utf8');
1587
+ * let rawData = '';
1588
+ * res.on('data', (chunk) => { rawData += chunk; });
1589
+ * res.on('end', () => {
1590
+ * try {
1591
+ * const parsedData = JSON.parse(rawData);
1592
+ * console.log(parsedData);
1593
+ * } catch (e) {
1594
+ * console.error(e.message);
1595
+ * }
1596
+ * });
1597
+ * }).on('error', (e) => {
1598
+ * console.error(`Got error: ${e.message}`);
1599
+ * });
1600
+ *
1601
+ * // Create a local server to receive data from
1602
+ * const server = http.createServer((req, res) => {
1603
+ * res.writeHead(200, { 'Content-Type': 'application/json' });
1604
+ * res.end(JSON.stringify({
1605
+ * data: 'Hello World!'
1606
+ * }));
1607
+ * });
1608
+ *
1609
+ * server.listen(8000);
1610
+ * ```
1611
+ * @since v0.3.6
1612
+ * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. Properties that are inherited from the prototype are ignored.
1613
+ */
1614
+ function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
1615
+ function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
1616
+
1617
+ /**
1618
+ * Performs the low-level validations on the provided name that are done when `res.setHeader(name, value)` is called.
1619
+ * Passing illegal value as name will result in a TypeError being thrown, identified by `code: 'ERR_INVALID_HTTP_TOKEN'`.
1620
+ * @param name Header name
1621
+ * @since v14.3.0
1622
+ */
1623
+ function validateHeaderName(name: string): void;
1624
+ /**
1625
+ * Performs the low-level validations on the provided value that are done when `res.setHeader(name, value)` is called.
1626
+ * Passing illegal value as value will result in a TypeError being thrown.
1627
+ * - Undefined value error is identified by `code: 'ERR_HTTP_INVALID_HEADER_VALUE'`.
1628
+ * - Invalid value character error is identified by `code: 'ERR_INVALID_CHAR'`.
1629
+ * @param name Header name
1630
+ * @param value Header value
1631
+ * @since v14.3.0
1632
+ */
1633
+ function validateHeaderValue(name: string, value: string): void;
1634
+
1635
+ /**
1636
+ * Set the maximum number of idle HTTP parsers. Default: 1000.
1637
+ * @param count
1638
+ * @since v18.8.0, v16.18.0
1639
+ */
1640
+ function setMaxIdleHTTPParsers(count: number): void;
1641
+
1642
+ let globalAgent: Agent;
1643
+ /**
1644
+ * Read-only property specifying the maximum allowed size of HTTP headers in bytes.
1645
+ * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
1646
+ */
1647
+ const maxHeaderSize: number;
1648
+ }
1649
+ declare module 'node:http' {
1650
+ export * from 'http';
1651
+ }
node_modules/@types/node/http2.d.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@types/node/https.d.ts ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
3
+ * separate module.
4
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js)
5
+ */
6
+ declare module 'https' {
7
+ import { Duplex } from 'node:stream';
8
+ import * as tls from 'node:tls';
9
+ import * as http from 'node:http';
10
+ import { URL } from 'node:url';
11
+ type ServerOptions<
12
+ Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
13
+ Response extends typeof http.ServerResponse = typeof http.ServerResponse,
14
+ > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
15
+ type RequestOptions = http.RequestOptions &
16
+ tls.SecureContextOptions & {
17
+ checkServerIdentity?: typeof tls.checkServerIdentity | undefined;
18
+ rejectUnauthorized?: boolean | undefined; // Defaults to true
19
+ servername?: string | undefined; // SNI TLS Extension
20
+ };
21
+ interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
22
+ rejectUnauthorized?: boolean | undefined;
23
+ maxCachedSessions?: number | undefined;
24
+ }
25
+ /**
26
+ * An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
27
+ * @since v0.4.5
28
+ */
29
+ class Agent extends http.Agent {
30
+ constructor(options?: AgentOptions);
31
+ options: AgentOptions;
32
+ }
33
+ interface Server<
34
+ Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
35
+ Response extends typeof http.ServerResponse = typeof http.ServerResponse,
36
+ > extends http.Server<Request, Response> {}
37
+ /**
38
+ * See `http.Server` for more information.
39
+ * @since v0.3.4
40
+ */
41
+ class Server<
42
+ Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
43
+ Response extends typeof http.ServerResponse = typeof http.ServerResponse,
44
+ > extends tls.Server {
45
+ constructor(requestListener?: http.RequestListener<Request, Response>);
46
+ constructor(
47
+ options: ServerOptions<Request, Response>,
48
+ requestListener?: http.RequestListener<Request, Response>,
49
+ );
50
+ /**
51
+ * Closes all connections connected to this server.
52
+ * @since v18.2.0
53
+ */
54
+ closeAllConnections(): void;
55
+ /**
56
+ * Closes all connections connected to this server which are not sending a request or waiting for a response.
57
+ * @since v18.2.0
58
+ */
59
+ closeIdleConnections(): void;
60
+ addListener(event: string, listener: (...args: any[]) => void): this;
61
+ addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
62
+ addListener(
63
+ event: 'newSession',
64
+ listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
65
+ ): this;
66
+ addListener(
67
+ event: 'OCSPRequest',
68
+ listener: (
69
+ certificate: Buffer,
70
+ issuer: Buffer,
71
+ callback: (err: Error | null, resp: Buffer) => void,
72
+ ) => void,
73
+ ): this;
74
+ addListener(
75
+ event: 'resumeSession',
76
+ listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
77
+ ): this;
78
+ addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
79
+ addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
80
+ addListener(event: 'close', listener: () => void): this;
81
+ addListener(event: 'connection', listener: (socket: Duplex) => void): this;
82
+ addListener(event: 'error', listener: (err: Error) => void): this;
83
+ addListener(event: 'listening', listener: () => void): this;
84
+ addListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
85
+ addListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
86
+ addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
87
+ addListener(
88
+ event: 'connect',
89
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
90
+ ): this;
91
+ addListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
92
+ addListener(
93
+ event: 'upgrade',
94
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
95
+ ): this;
96
+ emit(event: string, ...args: any[]): boolean;
97
+ emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean;
98
+ emit(
99
+ event: 'newSession',
100
+ sessionId: Buffer,
101
+ sessionData: Buffer,
102
+ callback: (err: Error, resp: Buffer) => void,
103
+ ): boolean;
104
+ emit(
105
+ event: 'OCSPRequest',
106
+ certificate: Buffer,
107
+ issuer: Buffer,
108
+ callback: (err: Error | null, resp: Buffer) => void,
109
+ ): boolean;
110
+ emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
111
+ emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean;
112
+ emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean;
113
+ emit(event: 'close'): boolean;
114
+ emit(event: 'connection', socket: Duplex): boolean;
115
+ emit(event: 'error', err: Error): boolean;
116
+ emit(event: 'listening'): boolean;
117
+ emit(
118
+ event: 'checkContinue',
119
+ req: InstanceType<Request>,
120
+ res: InstanceType<Response> & { req: InstanceType<Request> },
121
+ ): boolean;
122
+ emit(
123
+ event: 'checkExpectation',
124
+ req: InstanceType<Request>,
125
+ res: InstanceType<Response> & { req: InstanceType<Request> },
126
+ ): boolean;
127
+ emit(event: 'clientError', err: Error, socket: Duplex): boolean;
128
+ emit(event: 'connect', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
129
+ emit(
130
+ event: 'request',
131
+ req: InstanceType<Request>,
132
+ res: InstanceType<Response> & { req: InstanceType<Request> },
133
+ ): boolean;
134
+ emit(event: 'upgrade', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
135
+ on(event: string, listener: (...args: any[]) => void): this;
136
+ on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
137
+ on(
138
+ event: 'newSession',
139
+ listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
140
+ ): this;
141
+ on(
142
+ event: 'OCSPRequest',
143
+ listener: (
144
+ certificate: Buffer,
145
+ issuer: Buffer,
146
+ callback: (err: Error | null, resp: Buffer) => void,
147
+ ) => void,
148
+ ): this;
149
+ on(
150
+ event: 'resumeSession',
151
+ listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
152
+ ): this;
153
+ on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
154
+ on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
155
+ on(event: 'close', listener: () => void): this;
156
+ on(event: 'connection', listener: (socket: Duplex) => void): this;
157
+ on(event: 'error', listener: (err: Error) => void): this;
158
+ on(event: 'listening', listener: () => void): this;
159
+ on(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
160
+ on(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
161
+ on(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
162
+ on(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
163
+ on(event: 'request', listener: http.RequestListener<Request, Response>): this;
164
+ on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
165
+ once(event: string, listener: (...args: any[]) => void): this;
166
+ once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
167
+ once(
168
+ event: 'newSession',
169
+ listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
170
+ ): this;
171
+ once(
172
+ event: 'OCSPRequest',
173
+ listener: (
174
+ certificate: Buffer,
175
+ issuer: Buffer,
176
+ callback: (err: Error | null, resp: Buffer) => void,
177
+ ) => void,
178
+ ): this;
179
+ once(
180
+ event: 'resumeSession',
181
+ listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
182
+ ): this;
183
+ once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
184
+ once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
185
+ once(event: 'close', listener: () => void): this;
186
+ once(event: 'connection', listener: (socket: Duplex) => void): this;
187
+ once(event: 'error', listener: (err: Error) => void): this;
188
+ once(event: 'listening', listener: () => void): this;
189
+ once(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
190
+ once(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
191
+ once(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
192
+ once(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
193
+ once(event: 'request', listener: http.RequestListener<Request, Response>): this;
194
+ once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
195
+ prependListener(event: string, listener: (...args: any[]) => void): this;
196
+ prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
197
+ prependListener(
198
+ event: 'newSession',
199
+ listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
200
+ ): this;
201
+ prependListener(
202
+ event: 'OCSPRequest',
203
+ listener: (
204
+ certificate: Buffer,
205
+ issuer: Buffer,
206
+ callback: (err: Error | null, resp: Buffer) => void,
207
+ ) => void,
208
+ ): this;
209
+ prependListener(
210
+ event: 'resumeSession',
211
+ listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
212
+ ): this;
213
+ prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
214
+ prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
215
+ prependListener(event: 'close', listener: () => void): this;
216
+ prependListener(event: 'connection', listener: (socket: Duplex) => void): this;
217
+ prependListener(event: 'error', listener: (err: Error) => void): this;
218
+ prependListener(event: 'listening', listener: () => void): this;
219
+ prependListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
220
+ prependListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
221
+ prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
222
+ prependListener(
223
+ event: 'connect',
224
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
225
+ ): this;
226
+ prependListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
227
+ prependListener(
228
+ event: 'upgrade',
229
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
230
+ ): this;
231
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
232
+ prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
233
+ prependOnceListener(
234
+ event: 'newSession',
235
+ listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
236
+ ): this;
237
+ prependOnceListener(
238
+ event: 'OCSPRequest',
239
+ listener: (
240
+ certificate: Buffer,
241
+ issuer: Buffer,
242
+ callback: (err: Error | null, resp: Buffer) => void,
243
+ ) => void,
244
+ ): this;
245
+ prependOnceListener(
246
+ event: 'resumeSession',
247
+ listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
248
+ ): this;
249
+ prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
250
+ prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
251
+ prependOnceListener(event: 'close', listener: () => void): this;
252
+ prependOnceListener(event: 'connection', listener: (socket: Duplex) => void): this;
253
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
254
+ prependOnceListener(event: 'listening', listener: () => void): this;
255
+ prependOnceListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
256
+ prependOnceListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
257
+ prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
258
+ prependOnceListener(
259
+ event: 'connect',
260
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
261
+ ): this;
262
+ prependOnceListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
263
+ prependOnceListener(
264
+ event: 'upgrade',
265
+ listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
266
+ ): this;
267
+ }
268
+ /**
269
+ * ```js
270
+ * // curl -k https://localhost:8000/
271
+ * const https = require('https');
272
+ * const fs = require('fs');
273
+ *
274
+ * const options = {
275
+ * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
276
+ * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
277
+ * };
278
+ *
279
+ * https.createServer(options, (req, res) => {
280
+ * res.writeHead(200);
281
+ * res.end('hello world\n');
282
+ * }).listen(8000);
283
+ * ```
284
+ *
285
+ * Or
286
+ *
287
+ * ```js
288
+ * const https = require('https');
289
+ * const fs = require('fs');
290
+ *
291
+ * const options = {
292
+ * pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
293
+ * passphrase: 'sample'
294
+ * };
295
+ *
296
+ * https.createServer(options, (req, res) => {
297
+ * res.writeHead(200);
298
+ * res.end('hello world\n');
299
+ * }).listen(8000);
300
+ * ```
301
+ * @since v0.3.4
302
+ * @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
303
+ * @param requestListener A listener to be added to the `'request'` event.
304
+ */
305
+ function createServer<
306
+ Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
307
+ Response extends typeof http.ServerResponse = typeof http.ServerResponse,
308
+ >(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
309
+ function createServer<
310
+ Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
311
+ Response extends typeof http.ServerResponse = typeof http.ServerResponse,
312
+ >(
313
+ options: ServerOptions<Request, Response>,
314
+ requestListener?: http.RequestListener<Request, Response>,
315
+ ): Server<Request, Response>;
316
+ /**
317
+ * Makes a request to a secure web server.
318
+ *
319
+ * The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`,
320
+ * `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`.
321
+ *
322
+ * `options` can be an object, a string, or a `URL` object. If `options` is a
323
+ * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
324
+ *
325
+ * `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
326
+ * upload a file with a POST request, then write to the `ClientRequest` object.
327
+ *
328
+ * ```js
329
+ * const https = require('https');
330
+ *
331
+ * const options = {
332
+ * hostname: 'encrypted.google.com',
333
+ * port: 443,
334
+ * path: '/',
335
+ * method: 'GET'
336
+ * };
337
+ *
338
+ * const req = https.request(options, (res) => {
339
+ * console.log('statusCode:', res.statusCode);
340
+ * console.log('headers:', res.headers);
341
+ *
342
+ * res.on('data', (d) => {
343
+ * process.stdout.write(d);
344
+ * });
345
+ * });
346
+ *
347
+ * req.on('error', (e) => {
348
+ * console.error(e);
349
+ * });
350
+ * req.end();
351
+ * ```
352
+ *
353
+ * Example using options from `tls.connect()`:
354
+ *
355
+ * ```js
356
+ * const options = {
357
+ * hostname: 'encrypted.google.com',
358
+ * port: 443,
359
+ * path: '/',
360
+ * method: 'GET',
361
+ * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
362
+ * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
363
+ * };
364
+ * options.agent = new https.Agent(options);
365
+ *
366
+ * const req = https.request(options, (res) => {
367
+ * // ...
368
+ * });
369
+ * ```
370
+ *
371
+ * Alternatively, opt out of connection pooling by not using an `Agent`.
372
+ *
373
+ * ```js
374
+ * const options = {
375
+ * hostname: 'encrypted.google.com',
376
+ * port: 443,
377
+ * path: '/',
378
+ * method: 'GET',
379
+ * key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
380
+ * cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
381
+ * agent: false
382
+ * };
383
+ *
384
+ * const req = https.request(options, (res) => {
385
+ * // ...
386
+ * });
387
+ * ```
388
+ *
389
+ * Example using a `URL` as `options`:
390
+ *
391
+ * ```js
392
+ * const options = new URL('https://abc:[email protected]');
393
+ *
394
+ * const req = https.request(options, (res) => {
395
+ * // ...
396
+ * });
397
+ * ```
398
+ *
399
+ * Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
400
+ *
401
+ * ```js
402
+ * const tls = require('tls');
403
+ * const https = require('https');
404
+ * const crypto = require('crypto');
405
+ *
406
+ * function sha256(s) {
407
+ * return crypto.createHash('sha256').update(s).digest('base64');
408
+ * }
409
+ * const options = {
410
+ * hostname: 'github.com',
411
+ * port: 443,
412
+ * path: '/',
413
+ * method: 'GET',
414
+ * checkServerIdentity: function(host, cert) {
415
+ * // Make sure the certificate is issued to the host we are connected to
416
+ * const err = tls.checkServerIdentity(host, cert);
417
+ * if (err) {
418
+ * return err;
419
+ * }
420
+ *
421
+ * // Pin the public key, similar to HPKP pin-sha25 pinning
422
+ * const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
423
+ * if (sha256(cert.pubkey) !== pubkey256) {
424
+ * const msg = 'Certificate verification error: ' +
425
+ * `The public key of '${cert.subject.CN}' ` +
426
+ * 'does not match our pinned fingerprint';
427
+ * return new Error(msg);
428
+ * }
429
+ *
430
+ * // Pin the exact certificate, rather than the pub key
431
+ * const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
432
+ * 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
433
+ * if (cert.fingerprint256 !== cert256) {
434
+ * const msg = 'Certificate verification error: ' +
435
+ * `The certificate of '${cert.subject.CN}' ` +
436
+ * 'does not match our pinned fingerprint';
437
+ * return new Error(msg);
438
+ * }
439
+ *
440
+ * // This loop is informational only.
441
+ * // Print the certificate and public key fingerprints of all certs in the
442
+ * // chain. Its common to pin the public key of the issuer on the public
443
+ * // internet, while pinning the public key of the service in sensitive
444
+ * // environments.
445
+ * do {
446
+ * console.log('Subject Common Name:', cert.subject.CN);
447
+ * console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
448
+ *
449
+ * hash = crypto.createHash('sha256');
450
+ * console.log(' Public key ping-sha256:', sha256(cert.pubkey));
451
+ *
452
+ * lastprint256 = cert.fingerprint256;
453
+ * cert = cert.issuerCertificate;
454
+ * } while (cert.fingerprint256 !== lastprint256);
455
+ *
456
+ * },
457
+ * };
458
+ *
459
+ * options.agent = new https.Agent(options);
460
+ * const req = https.request(options, (res) => {
461
+ * console.log('All OK. Server matched our pinned cert or public key');
462
+ * console.log('statusCode:', res.statusCode);
463
+ * // Print the HPKP values
464
+ * console.log('headers:', res.headers['public-key-pins']);
465
+ *
466
+ * res.on('data', (d) => {});
467
+ * });
468
+ *
469
+ * req.on('error', (e) => {
470
+ * console.error(e.message);
471
+ * });
472
+ * req.end();
473
+ * ```
474
+ *
475
+ * Outputs for example:
476
+ *
477
+ * ```text
478
+ * Subject Common Name: github.com
479
+ * Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
480
+ * Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
481
+ * Subject Common Name: DigiCert SHA2 Extended Validation Server CA
482
+ * Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
483
+ * Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
484
+ * Subject Common Name: DigiCert High Assurance EV Root CA
485
+ * Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
486
+ * Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
487
+ * All OK. Server matched our pinned cert or public key
488
+ * statusCode: 200
489
+ * headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
490
+ * pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
491
+ * pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
492
+ * ```
493
+ * @since v0.3.6
494
+ * @param options Accepts all `options` from `request`, with some differences in default values:
495
+ */
496
+ function request(
497
+ options: RequestOptions | string | URL,
498
+ callback?: (res: http.IncomingMessage) => void,
499
+ ): http.ClientRequest;
500
+ function request(
501
+ url: string | URL,
502
+ options: RequestOptions,
503
+ callback?: (res: http.IncomingMessage) => void,
504
+ ): http.ClientRequest;
505
+ /**
506
+ * Like `http.get()` but for HTTPS.
507
+ *
508
+ * `options` can be an object, a string, or a `URL` object. If `options` is a
509
+ * string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
510
+ *
511
+ * ```js
512
+ * const https = require('https');
513
+ *
514
+ * https.get('https://encrypted.google.com/', (res) => {
515
+ * console.log('statusCode:', res.statusCode);
516
+ * console.log('headers:', res.headers);
517
+ *
518
+ * res.on('data', (d) => {
519
+ * process.stdout.write(d);
520
+ * });
521
+ *
522
+ * }).on('error', (e) => {
523
+ * console.error(e);
524
+ * });
525
+ * ```
526
+ * @since v0.3.6
527
+ * @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
528
+ */
529
+ function get(
530
+ options: RequestOptions | string | URL,
531
+ callback?: (res: http.IncomingMessage) => void,
532
+ ): http.ClientRequest;
533
+ function get(
534
+ url: string | URL,
535
+ options: RequestOptions,
536
+ callback?: (res: http.IncomingMessage) => void,
537
+ ): http.ClientRequest;
538
+ let globalAgent: Agent;
539
+ }
540
+ declare module 'node:https' {
541
+ export * from 'https';
542
+ }
node_modules/@types/node/index.d.ts ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Type definitions for non-npm package Node.js 18.15
2
+ // Project: https://nodejs.org/
3
+ // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
+ // DefinitelyTyped <https://github.com/DefinitelyTyped>
5
+ // Alberto Schiabel <https://github.com/jkomyno>
6
+ // Alvis HT Tang <https://github.com/alvis>
7
+ // Andrew Makarov <https://github.com/r3nya>
8
+ // Benjamin Toueg <https://github.com/btoueg>
9
+ // Chigozirim C. <https://github.com/smac89>
10
+ // David Junger <https://github.com/touffy>
11
+ // Deividas Bakanas <https://github.com/DeividasBakanas>
12
+ // Eugene Y. Q. Shen <https://github.com/eyqs>
13
+ // Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
14
+ // Huw <https://github.com/hoo29>
15
+ // Kelvin Jin <https://github.com/kjin>
16
+ // Klaus Meinhardt <https://github.com/ajafff>
17
+ // Lishude <https://github.com/islishude>
18
+ // Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
19
+ // Mohsen Azimi <https://github.com/mohsen1>
20
+ // Nicolas Even <https://github.com/n-e>
21
+ // Nikita Galkin <https://github.com/galkin>
22
+ // Parambir Singh <https://github.com/parambirs>
23
+ // Sebastian Silbermann <https://github.com/eps1lon>
24
+ // Simon Schick <https://github.com/SimonSchick>
25
+ // Thomas den Hollander <https://github.com/ThomasdenH>
26
+ // Wilco Bakker <https://github.com/WilcoBakker>
27
+ // wwwy3y3 <https://github.com/wwwy3y3>
28
+ // Samuel Ainsworth <https://github.com/samuela>
29
+ // Kyle Uehlein <https://github.com/kuehlein>
30
+ // Thanik Bhongbhibhat <https://github.com/bhongy>
31
+ // Marcin Kopacz <https://github.com/chyzwar>
32
+ // Trivikram Kamat <https://github.com/trivikr>
33
+ // Junxiao Shi <https://github.com/yoursunny>
34
+ // Ilia Baryshnikov <https://github.com/qwelias>
35
+ // ExE Boss <https://github.com/ExE-Boss>
36
+ // Piotr Błażejewicz <https://github.com/peterblazejewicz>
37
+ // Anna Henningsen <https://github.com/addaleax>
38
+ // Victor Perin <https://github.com/victorperin>
39
+ // Yongsheng Zhang <https://github.com/ZYSzys>
40
+ // NodeJS Contributors <https://github.com/NodeJS>
41
+ // Linus Unnebäck <https://github.com/LinusU>
42
+ // wafuwafu13 <https://github.com/wafuwafu13>
43
+ // Matteo Collina <https://github.com/mcollina>
44
+ // Dmitry Semigradsky <https://github.com/Semigradsky>
45
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
46
+
47
+ /**
48
+ * License for programmatically and manually incorporated
49
+ * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
50
+ *
51
+ * Copyright Node.js contributors. All rights reserved.
52
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
53
+ * of this software and associated documentation files (the "Software"), to
54
+ * deal in the Software without restriction, including without limitation the
55
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
56
+ * sell copies of the Software, and to permit persons to whom the Software is
57
+ * furnished to do so, subject to the following conditions:
58
+ *
59
+ * The above copyright notice and this permission notice shall be included in
60
+ * all copies or substantial portions of the Software.
61
+ *
62
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
67
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
68
+ * IN THE SOFTWARE.
69
+ */
70
+
71
+ // NOTE: These definitions support NodeJS and TypeScript 4.9+.
72
+
73
+ // Reference required types from the default lib:
74
+ /// <reference lib="es2020" />
75
+ /// <reference lib="esnext.asynciterable" />
76
+ /// <reference lib="esnext.intl" />
77
+ /// <reference lib="esnext.bigint" />
78
+
79
+ // Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
80
+ /// <reference path="assert.d.ts" />
81
+ /// <reference path="assert/strict.d.ts" />
82
+ /// <reference path="globals.d.ts" />
83
+ /// <reference path="async_hooks.d.ts" />
84
+ /// <reference path="buffer.d.ts" />
85
+ /// <reference path="child_process.d.ts" />
86
+ /// <reference path="cluster.d.ts" />
87
+ /// <reference path="console.d.ts" />
88
+ /// <reference path="constants.d.ts" />
89
+ /// <reference path="crypto.d.ts" />
90
+ /// <reference path="dgram.d.ts" />
91
+ /// <reference path="diagnostics_channel.d.ts" />
92
+ /// <reference path="dns.d.ts" />
93
+ /// <reference path="dns/promises.d.ts" />
94
+ /// <reference path="dns/promises.d.ts" />
95
+ /// <reference path="domain.d.ts" />
96
+ /// <reference path="dom-events.d.ts" />
97
+ /// <reference path="events.d.ts" />
98
+ /// <reference path="fs.d.ts" />
99
+ /// <reference path="fs/promises.d.ts" />
100
+ /// <reference path="http.d.ts" />
101
+ /// <reference path="http2.d.ts" />
102
+ /// <reference path="https.d.ts" />
103
+ /// <reference path="inspector.d.ts" />
104
+ /// <reference path="module.d.ts" />
105
+ /// <reference path="net.d.ts" />
106
+ /// <reference path="os.d.ts" />
107
+ /// <reference path="path.d.ts" />
108
+ /// <reference path="perf_hooks.d.ts" />
109
+ /// <reference path="process.d.ts" />
110
+ /// <reference path="punycode.d.ts" />
111
+ /// <reference path="querystring.d.ts" />
112
+ /// <reference path="readline.d.ts" />
113
+ /// <reference path="readline/promises.d.ts" />
114
+ /// <reference path="repl.d.ts" />
115
+ /// <reference path="stream.d.ts" />
116
+ /// <reference path="stream/promises.d.ts" />
117
+ /// <reference path="stream/consumers.d.ts" />
118
+ /// <reference path="stream/web.d.ts" />
119
+ /// <reference path="string_decoder.d.ts" />
120
+ /// <reference path="test.d.ts" />
121
+ /// <reference path="timers.d.ts" />
122
+ /// <reference path="timers/promises.d.ts" />
123
+ /// <reference path="tls.d.ts" />
124
+ /// <reference path="trace_events.d.ts" />
125
+ /// <reference path="tty.d.ts" />
126
+ /// <reference path="url.d.ts" />
127
+ /// <reference path="util.d.ts" />
128
+ /// <reference path="v8.d.ts" />
129
+ /// <reference path="vm.d.ts" />
130
+ /// <reference path="wasi.d.ts" />
131
+ /// <reference path="worker_threads.d.ts" />
132
+ /// <reference path="zlib.d.ts" />
133
+
134
+ /// <reference path="globals.global.d.ts" />
node_modules/@types/node/inspector.d.ts ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@types/node/module.d.ts ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @since v0.3.7
3
+ */
4
+ declare module 'module' {
5
+ import { URL } from 'node:url';
6
+ namespace Module {
7
+ /**
8
+ * The `module.syncBuiltinESMExports()` method updates all the live bindings for
9
+ * builtin `ES Modules` to match the properties of the `CommonJS` exports. It
10
+ * does not add or remove exported names from the `ES Modules`.
11
+ *
12
+ * ```js
13
+ * const fs = require('fs');
14
+ * const assert = require('assert');
15
+ * const { syncBuiltinESMExports } = require('module');
16
+ *
17
+ * fs.readFile = newAPI;
18
+ *
19
+ * delete fs.readFileSync;
20
+ *
21
+ * function newAPI() {
22
+ * // ...
23
+ * }
24
+ *
25
+ * fs.newAPI = newAPI;
26
+ *
27
+ * syncBuiltinESMExports();
28
+ *
29
+ * import('fs').then((esmFS) => {
30
+ * // It syncs the existing readFile property with the new value
31
+ * assert.strictEqual(esmFS.readFile, newAPI);
32
+ * // readFileSync has been deleted from the required fs
33
+ * assert.strictEqual('readFileSync' in fs, false);
34
+ * // syncBuiltinESMExports() does not remove readFileSync from esmFS
35
+ * assert.strictEqual('readFileSync' in esmFS, true);
36
+ * // syncBuiltinESMExports() does not add names
37
+ * assert.strictEqual(esmFS.newAPI, undefined);
38
+ * });
39
+ * ```
40
+ * @since v12.12.0
41
+ */
42
+ function syncBuiltinESMExports(): void;
43
+ /**
44
+ * `path` is the resolved path for the file for which a corresponding source map
45
+ * should be fetched.
46
+ * @since v13.7.0, v12.17.0
47
+ */
48
+ function findSourceMap(path: string, error?: Error): SourceMap;
49
+ interface SourceMapPayload {
50
+ file: string;
51
+ version: number;
52
+ sources: string[];
53
+ sourcesContent: string[];
54
+ names: string[];
55
+ mappings: string;
56
+ sourceRoot: string;
57
+ }
58
+ interface SourceMapping {
59
+ generatedLine: number;
60
+ generatedColumn: number;
61
+ originalSource: string;
62
+ originalLine: number;
63
+ originalColumn: number;
64
+ }
65
+ /**
66
+ * @since v13.7.0, v12.17.0
67
+ */
68
+ class SourceMap {
69
+ /**
70
+ * Getter for the payload used to construct the `SourceMap` instance.
71
+ */
72
+ readonly payload: SourceMapPayload;
73
+ constructor(payload: SourceMapPayload);
74
+ /**
75
+ * Given a line number and column number in the generated source file, returns
76
+ * an object representing the position in the original file. The object returned
77
+ * consists of the following keys:
78
+ */
79
+ findEntry(line: number, column: number): SourceMapping;
80
+ }
81
+ }
82
+ interface Module extends NodeModule {}
83
+ class Module {
84
+ static runMain(): void;
85
+ static wrap(code: string): string;
86
+ static createRequire(path: string | URL): NodeRequire;
87
+ static builtinModules: string[];
88
+ static isBuiltin(moduleName: string): boolean;
89
+ static Module: typeof Module;
90
+ constructor(id: string, parent?: Module);
91
+ }
92
+ global {
93
+ interface ImportMeta {
94
+ url: string;
95
+ /**
96
+ * @experimental
97
+ * This feature is only available with the `--experimental-import-meta-resolve`
98
+ * command flag enabled.
99
+ *
100
+ * Provides a module-relative resolution function scoped to each module, returning
101
+ * the URL string.
102
+ *
103
+ * @param specified The module specifier to resolve relative to `parent`.
104
+ * @param parent The absolute parent module URL to resolve from. If none
105
+ * is specified, the value of `import.meta.url` is used as the default.
106
+ */
107
+ resolve?(specified: string, parent?: string | URL): Promise<string>;
108
+ }
109
+ }
110
+ export = Module;
111
+ }
112
+ declare module 'node:module' {
113
+ import module = require('module');
114
+ export = module;
115
+ }
node_modules/@types/node/net.d.ts ADDED
@@ -0,0 +1,883 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * > Stability: 2 - Stable
3
+ *
4
+ * The `net` module provides an asynchronous network API for creating stream-based
5
+ * TCP or `IPC` servers ({@link createServer}) and clients
6
+ * ({@link createConnection}).
7
+ *
8
+ * It can be accessed using:
9
+ *
10
+ * ```js
11
+ * const net = require('net');
12
+ * ```
13
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js)
14
+ */
15
+ declare module 'net' {
16
+ import * as stream from 'node:stream';
17
+ import { Abortable, EventEmitter } from 'node:events';
18
+ import * as dns from 'node:dns';
19
+ type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
20
+ interface AddressInfo {
21
+ address: string;
22
+ family: string;
23
+ port: number;
24
+ }
25
+ interface SocketConstructorOpts {
26
+ fd?: number | undefined;
27
+ allowHalfOpen?: boolean | undefined;
28
+ readable?: boolean | undefined;
29
+ writable?: boolean | undefined;
30
+ signal?: AbortSignal;
31
+ }
32
+ interface OnReadOpts {
33
+ buffer: Uint8Array | (() => Uint8Array);
34
+ /**
35
+ * This function is called for every chunk of incoming data.
36
+ * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
37
+ * Return false from this function to implicitly pause() the socket.
38
+ */
39
+ callback(bytesWritten: number, buf: Uint8Array): boolean;
40
+ }
41
+ interface ConnectOpts {
42
+ /**
43
+ * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
44
+ * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
45
+ * still be emitted as normal and methods like pause() and resume() will also behave as expected.
46
+ */
47
+ onread?: OnReadOpts | undefined;
48
+ }
49
+ interface TcpSocketConnectOpts extends ConnectOpts {
50
+ port: number;
51
+ host?: string | undefined;
52
+ localAddress?: string | undefined;
53
+ localPort?: number | undefined;
54
+ hints?: number | undefined;
55
+ family?: number | undefined;
56
+ lookup?: LookupFunction | undefined;
57
+ noDelay?: boolean | undefined;
58
+ keepAlive?: boolean | undefined;
59
+ keepAliveInitialDelay?: number | undefined;
60
+ /**
61
+ * @since v18.13.0
62
+ */
63
+ autoSelectFamily?: boolean | undefined;
64
+ /**
65
+ * @since v18.13.0
66
+ */
67
+ autoSelectFamilyAttemptTimeout?: number | undefined;
68
+ }
69
+ interface IpcSocketConnectOpts extends ConnectOpts {
70
+ path: string;
71
+ }
72
+ type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
73
+ type SocketReadyState = 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
74
+ /**
75
+ * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
76
+ * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
77
+ * an `EventEmitter`.
78
+ *
79
+ * A `net.Socket` can be created by the user and used directly to interact with
80
+ * a server. For example, it is returned by {@link createConnection},
81
+ * so the user can use it to talk to the server.
82
+ *
83
+ * It can also be created by Node.js and passed to the user when a connection
84
+ * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
85
+ * it to interact with the client.
86
+ * @since v0.3.4
87
+ */
88
+ class Socket extends stream.Duplex {
89
+ constructor(options?: SocketConstructorOpts);
90
+ /**
91
+ * Sends data on the socket. The second parameter specifies the encoding in the
92
+ * case of a string. It defaults to UTF8 encoding.
93
+ *
94
+ * Returns `true` if the entire data was flushed successfully to the kernel
95
+ * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
96
+ *
97
+ * The optional `callback` parameter will be executed when the data is finally
98
+ * written out, which may not be immediately.
99
+ *
100
+ * See `Writable` stream `write()` method for more
101
+ * information.
102
+ * @since v0.1.90
103
+ * @param [encoding='utf8'] Only used when data is `string`.
104
+ */
105
+ write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
106
+ write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
107
+ /**
108
+ * Initiate a connection on a given socket.
109
+ *
110
+ * Possible signatures:
111
+ *
112
+ * * `socket.connect(options[, connectListener])`
113
+ * * `socket.connect(path[, connectListener])` for `IPC` connections.
114
+ * * `socket.connect(port[, host][, connectListener])` for TCP connections.
115
+ * * Returns: `net.Socket` The socket itself.
116
+ *
117
+ * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
118
+ * instead of a `'connect'` event, an `'error'` event will be emitted with
119
+ * the error passed to the `'error'` listener.
120
+ * The last parameter `connectListener`, if supplied, will be added as a listener
121
+ * for the `'connect'` event **once**.
122
+ *
123
+ * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
124
+ * behavior.
125
+ */
126
+ connect(options: SocketConnectOpts, connectionListener?: () => void): this;
127
+ connect(port: number, host: string, connectionListener?: () => void): this;
128
+ connect(port: number, connectionListener?: () => void): this;
129
+ connect(path: string, connectionListener?: () => void): this;
130
+ /**
131
+ * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
132
+ * @since v0.1.90
133
+ * @return The socket itself.
134
+ */
135
+ setEncoding(encoding?: BufferEncoding): this;
136
+ /**
137
+ * Pauses the reading of data. That is, `'data'` events will not be emitted.
138
+ * Useful to throttle back an upload.
139
+ * @return The socket itself.
140
+ */
141
+ pause(): this;
142
+ /**
143
+ * Close the TCP connection by sending an RST packet and destroy the stream.
144
+ * If this TCP socket is in connecting status, it will send an RST packet
145
+ * and destroy this TCP socket once it is connected. Otherwise, it will call
146
+ * `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket
147
+ * (for example, a pipe), calling this method will immediately throw
148
+ * an `ERR_INVALID_HANDLE_TYPE` Error.
149
+ * @since v18.3.0
150
+ * @return The socket itself.
151
+ */
152
+ resetAndDestroy(): this;
153
+ /**
154
+ * Resumes reading after a call to `socket.pause()`.
155
+ * @return The socket itself.
156
+ */
157
+ resume(): this;
158
+ /**
159
+ * Sets the socket to timeout after `timeout` milliseconds of inactivity on
160
+ * the socket. By default `net.Socket` do not have a timeout.
161
+ *
162
+ * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
163
+ * end the connection.
164
+ *
165
+ * ```js
166
+ * socket.setTimeout(3000);
167
+ * socket.on('timeout', () => {
168
+ * console.log('socket timeout');
169
+ * socket.end();
170
+ * });
171
+ * ```
172
+ *
173
+ * If `timeout` is 0, then the existing idle timeout is disabled.
174
+ *
175
+ * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
176
+ * @since v0.1.90
177
+ * @return The socket itself.
178
+ */
179
+ setTimeout(timeout: number, callback?: () => void): this;
180
+ /**
181
+ * Enable/disable the use of Nagle's algorithm.
182
+ *
183
+ * When a TCP connection is created, it will have Nagle's algorithm enabled.
184
+ *
185
+ * Nagle's algorithm delays data before it is sent via the network. It attempts
186
+ * to optimize throughput at the expense of latency.
187
+ *
188
+ * Passing `true` for `noDelay` or not passing an argument will disable Nagle's
189
+ * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
190
+ * algorithm.
191
+ * @since v0.1.90
192
+ * @param [noDelay=true]
193
+ * @return The socket itself.
194
+ */
195
+ setNoDelay(noDelay?: boolean): this;
196
+ /**
197
+ * Enable/disable keep-alive functionality, and optionally set the initial
198
+ * delay before the first keepalive probe is sent on an idle socket.
199
+ *
200
+ * Set `initialDelay` (in milliseconds) to set the delay between the last
201
+ * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
202
+ * (or previous) setting.
203
+ *
204
+ * Enabling the keep-alive functionality will set the following socket options:
205
+ *
206
+ * * `SO_KEEPALIVE=1`
207
+ * * `TCP_KEEPIDLE=initialDelay`
208
+ * * `TCP_KEEPCNT=10`
209
+ * * `TCP_KEEPINTVL=1`
210
+ * @since v0.1.92
211
+ * @param [enable=false]
212
+ * @param [initialDelay=0]
213
+ * @return The socket itself.
214
+ */
215
+ setKeepAlive(enable?: boolean, initialDelay?: number): this;
216
+ /**
217
+ * Returns the bound `address`, the address `family` name and `port` of the
218
+ * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
219
+ * @since v0.1.90
220
+ */
221
+ address(): AddressInfo | {};
222
+ /**
223
+ * Calling `unref()` on a socket will allow the program to exit if this is the only
224
+ * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
225
+ * @since v0.9.1
226
+ * @return The socket itself.
227
+ */
228
+ unref(): this;
229
+ /**
230
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior).
231
+ * If the socket is `ref`ed calling `ref` again will have no effect.
232
+ * @since v0.9.1
233
+ * @return The socket itself.
234
+ */
235
+ ref(): this;
236
+ /**
237
+ * This property shows the number of characters buffered for writing. The buffer
238
+ * may contain strings whose length after encoding is not yet known. So this number
239
+ * is only an approximation of the number of bytes in the buffer.
240
+ *
241
+ * `net.Socket` has the property that `socket.write()` always works. This is to
242
+ * help users get up and running quickly. The computer cannot always keep up
243
+ * with the amount of data that is written to a socket. The network connection
244
+ * simply might be too slow. Node.js will internally queue up the data written to a
245
+ * socket and send it out over the wire when it is possible.
246
+ *
247
+ * The consequence of this internal buffering is that memory may grow.
248
+ * Users who experience large or growing `bufferSize` should attempt to
249
+ * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
250
+ * @since v0.3.8
251
+ * @deprecated Since v14.6.0 - Use `writableLength` instead.
252
+ */
253
+ readonly bufferSize: number;
254
+ /**
255
+ * The amount of received bytes.
256
+ * @since v0.5.3
257
+ */
258
+ readonly bytesRead: number;
259
+ /**
260
+ * The amount of bytes sent.
261
+ * @since v0.5.3
262
+ */
263
+ readonly bytesWritten: number;
264
+ /**
265
+ * If `true`,`socket.connect(options[, connectListener])` was
266
+ * called and has not yet finished. It will stay `true` until the socket becomes
267
+ * connected, then it is set to `false` and the `'connect'` event is emitted. Note
268
+ * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
269
+ * @since v6.1.0
270
+ */
271
+ readonly connecting: boolean;
272
+ /**
273
+ * This is `true` if the socket is not connected yet, either because `.connect()`
274
+ * has not yet been called or because it is still in the process of connecting (see `socket.connecting`).
275
+ * @since v10.16.0
276
+ */
277
+ readonly pending: boolean;
278
+ /**
279
+ * See `writable.destroyed` for further details.
280
+ */
281
+ readonly destroyed: boolean;
282
+ /**
283
+ * The string representation of the local IP address the remote client is
284
+ * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
285
+ * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
286
+ * @since v0.9.6
287
+ */
288
+ readonly localAddress?: string;
289
+ /**
290
+ * The numeric representation of the local port. For example, `80` or `21`.
291
+ * @since v0.9.6
292
+ */
293
+ readonly localPort?: number;
294
+ /**
295
+ * The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
296
+ * @since v18.8.0
297
+ */
298
+ readonly localFamily?: string;
299
+ /**
300
+ * This property represents the state of the connection as a string.
301
+ * @see {https://nodejs.org/api/net.html#socketreadystate}
302
+ * @since v0.5.0
303
+ */
304
+ readonly readyState: SocketReadyState;
305
+ /**
306
+ * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
307
+ * the socket is destroyed (for example, if the client disconnected).
308
+ * @since v0.5.10
309
+ */
310
+ readonly remoteAddress?: string | undefined;
311
+ /**
312
+ * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
313
+ * @since v0.11.14
314
+ */
315
+ readonly remoteFamily?: string | undefined;
316
+ /**
317
+ * The numeric representation of the remote port. For example, `80` or `21`.
318
+ * @since v0.5.10
319
+ */
320
+ readonly remotePort?: number | undefined;
321
+ /**
322
+ * The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set.
323
+ * @since v10.7.0
324
+ */
325
+ readonly timeout?: number | undefined;
326
+ /**
327
+ * Half-closes the socket. i.e., it sends a FIN packet. It is possible the
328
+ * server will still send some data.
329
+ *
330
+ * See `writable.end()` for further details.
331
+ * @since v0.1.90
332
+ * @param [encoding='utf8'] Only used when data is `string`.
333
+ * @param callback Optional callback for when the socket is finished.
334
+ * @return The socket itself.
335
+ */
336
+ end(callback?: () => void): this;
337
+ end(buffer: Uint8Array | string, callback?: () => void): this;
338
+ end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
339
+ /**
340
+ * events.EventEmitter
341
+ * 1. close
342
+ * 2. connect
343
+ * 3. data
344
+ * 4. drain
345
+ * 5. end
346
+ * 6. error
347
+ * 7. lookup
348
+ * 8. ready
349
+ * 9. timeout
350
+ */
351
+ addListener(event: string, listener: (...args: any[]) => void): this;
352
+ addListener(event: 'close', listener: (hadError: boolean) => void): this;
353
+ addListener(event: 'connect', listener: () => void): this;
354
+ addListener(event: 'data', listener: (data: Buffer) => void): this;
355
+ addListener(event: 'drain', listener: () => void): this;
356
+ addListener(event: 'end', listener: () => void): this;
357
+ addListener(event: 'error', listener: (err: Error) => void): this;
358
+ addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
359
+ addListener(event: 'ready', listener: () => void): this;
360
+ addListener(event: 'timeout', listener: () => void): this;
361
+ emit(event: string | symbol, ...args: any[]): boolean;
362
+ emit(event: 'close', hadError: boolean): boolean;
363
+ emit(event: 'connect'): boolean;
364
+ emit(event: 'data', data: Buffer): boolean;
365
+ emit(event: 'drain'): boolean;
366
+ emit(event: 'end'): boolean;
367
+ emit(event: 'error', err: Error): boolean;
368
+ emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
369
+ emit(event: 'ready'): boolean;
370
+ emit(event: 'timeout'): boolean;
371
+ on(event: string, listener: (...args: any[]) => void): this;
372
+ on(event: 'close', listener: (hadError: boolean) => void): this;
373
+ on(event: 'connect', listener: () => void): this;
374
+ on(event: 'data', listener: (data: Buffer) => void): this;
375
+ on(event: 'drain', listener: () => void): this;
376
+ on(event: 'end', listener: () => void): this;
377
+ on(event: 'error', listener: (err: Error) => void): this;
378
+ on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
379
+ on(event: 'ready', listener: () => void): this;
380
+ on(event: 'timeout', listener: () => void): this;
381
+ once(event: string, listener: (...args: any[]) => void): this;
382
+ once(event: 'close', listener: (hadError: boolean) => void): this;
383
+ once(event: 'connect', listener: () => void): this;
384
+ once(event: 'data', listener: (data: Buffer) => void): this;
385
+ once(event: 'drain', listener: () => void): this;
386
+ once(event: 'end', listener: () => void): this;
387
+ once(event: 'error', listener: (err: Error) => void): this;
388
+ once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
389
+ once(event: 'ready', listener: () => void): this;
390
+ once(event: 'timeout', listener: () => void): this;
391
+ prependListener(event: string, listener: (...args: any[]) => void): this;
392
+ prependListener(event: 'close', listener: (hadError: boolean) => void): this;
393
+ prependListener(event: 'connect', listener: () => void): this;
394
+ prependListener(event: 'data', listener: (data: Buffer) => void): this;
395
+ prependListener(event: 'drain', listener: () => void): this;
396
+ prependListener(event: 'end', listener: () => void): this;
397
+ prependListener(event: 'error', listener: (err: Error) => void): this;
398
+ prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
399
+ prependListener(event: 'ready', listener: () => void): this;
400
+ prependListener(event: 'timeout', listener: () => void): this;
401
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
402
+ prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
403
+ prependOnceListener(event: 'connect', listener: () => void): this;
404
+ prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
405
+ prependOnceListener(event: 'drain', listener: () => void): this;
406
+ prependOnceListener(event: 'end', listener: () => void): this;
407
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
408
+ prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
409
+ prependOnceListener(event: 'ready', listener: () => void): this;
410
+ prependOnceListener(event: 'timeout', listener: () => void): this;
411
+ }
412
+ interface ListenOptions extends Abortable {
413
+ port?: number | undefined;
414
+ host?: string | undefined;
415
+ backlog?: number | undefined;
416
+ path?: string | undefined;
417
+ exclusive?: boolean | undefined;
418
+ readableAll?: boolean | undefined;
419
+ writableAll?: boolean | undefined;
420
+ /**
421
+ * @default false
422
+ */
423
+ ipv6Only?: boolean | undefined;
424
+ }
425
+ interface ServerOpts {
426
+ /**
427
+ * Indicates whether half-opened TCP connections are allowed.
428
+ * @default false
429
+ */
430
+ allowHalfOpen?: boolean | undefined;
431
+ /**
432
+ * Indicates whether the socket should be paused on incoming connections.
433
+ * @default false
434
+ */
435
+ pauseOnConnect?: boolean | undefined;
436
+ /**
437
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
438
+ * @default false
439
+ * @since v16.5.0
440
+ */
441
+ noDelay?: boolean | undefined;
442
+ /**
443
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
444
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
445
+ * @default false
446
+ * @since v16.5.0
447
+ */
448
+ keepAlive?: boolean | undefined;
449
+ /**
450
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
451
+ * @default 0
452
+ * @since v16.5.0
453
+ */
454
+ keepAliveInitialDelay?: number | undefined;
455
+ }
456
+ interface DropArgument {
457
+ localAddress?: string;
458
+ localPort?: number;
459
+ localFamily?: string;
460
+ remoteAddress?: string;
461
+ remotePort?: number;
462
+ remoteFamily?: string;
463
+ }
464
+ /**
465
+ * This class is used to create a TCP or `IPC` server.
466
+ * @since v0.1.90
467
+ */
468
+ class Server extends EventEmitter {
469
+ constructor(connectionListener?: (socket: Socket) => void);
470
+ constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
471
+ /**
472
+ * Start a server listening for connections. A `net.Server` can be a TCP or
473
+ * an `IPC` server depending on what it listens to.
474
+ *
475
+ * Possible signatures:
476
+ *
477
+ * * `server.listen(handle[, backlog][, callback])`
478
+ * * `server.listen(options[, callback])`
479
+ * * `server.listen(path[, backlog][, callback])` for `IPC` servers
480
+ * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
481
+ *
482
+ * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
483
+ * event.
484
+ *
485
+ * All `listen()` methods can take a `backlog` parameter to specify the maximum
486
+ * length of the queue of pending connections. The actual length will be determined
487
+ * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
488
+ *
489
+ * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
490
+ * details).
491
+ *
492
+ * The `server.listen()` method can be called again if and only if there was an
493
+ * error during the first `server.listen()` call or `server.close()` has been
494
+ * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
495
+ *
496
+ * One of the most common errors raised when listening is `EADDRINUSE`.
497
+ * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
498
+ * after a certain amount of time:
499
+ *
500
+ * ```js
501
+ * server.on('error', (e) => {
502
+ * if (e.code === 'EADDRINUSE') {
503
+ * console.log('Address in use, retrying...');
504
+ * setTimeout(() => {
505
+ * server.close();
506
+ * server.listen(PORT, HOST);
507
+ * }, 1000);
508
+ * }
509
+ * });
510
+ * ```
511
+ */
512
+ listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
513
+ listen(port?: number, hostname?: string, listeningListener?: () => void): this;
514
+ listen(port?: number, backlog?: number, listeningListener?: () => void): this;
515
+ listen(port?: number, listeningListener?: () => void): this;
516
+ listen(path: string, backlog?: number, listeningListener?: () => void): this;
517
+ listen(path: string, listeningListener?: () => void): this;
518
+ listen(options: ListenOptions, listeningListener?: () => void): this;
519
+ listen(handle: any, backlog?: number, listeningListener?: () => void): this;
520
+ listen(handle: any, listeningListener?: () => void): this;
521
+ /**
522
+ * Stops the server from accepting new connections and keeps existing
523
+ * connections. This function is asynchronous, the server is finally closed
524
+ * when all connections are ended and the server emits a `'close'` event.
525
+ * The optional `callback` will be called once the `'close'` event occurs. Unlike
526
+ * that event, it will be called with an `Error` as its only argument if the server
527
+ * was not open when it was closed.
528
+ * @since v0.1.90
529
+ * @param callback Called when the server is closed.
530
+ */
531
+ close(callback?: (err?: Error) => void): this;
532
+ /**
533
+ * Returns the bound `address`, the address `family` name, and `port` of the server
534
+ * as reported by the operating system if listening on an IP socket
535
+ * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
536
+ *
537
+ * For a server listening on a pipe or Unix domain socket, the name is returned
538
+ * as a string.
539
+ *
540
+ * ```js
541
+ * const server = net.createServer((socket) => {
542
+ * socket.end('goodbye\n');
543
+ * }).on('error', (err) => {
544
+ * // Handle errors here.
545
+ * throw err;
546
+ * });
547
+ *
548
+ * // Grab an arbitrary unused port.
549
+ * server.listen(() => {
550
+ * console.log('opened server on', server.address());
551
+ * });
552
+ * ```
553
+ *
554
+ * `server.address()` returns `null` before the `'listening'` event has been
555
+ * emitted or after calling `server.close()`.
556
+ * @since v0.1.90
557
+ */
558
+ address(): AddressInfo | string | null;
559
+ /**
560
+ * Asynchronously get the number of concurrent connections on the server. Works
561
+ * when sockets were sent to forks.
562
+ *
563
+ * Callback should take two arguments `err` and `count`.
564
+ * @since v0.9.7
565
+ */
566
+ getConnections(cb: (error: Error | null, count: number) => void): void;
567
+ /**
568
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior).
569
+ * If the server is `ref`ed calling `ref()` again will have no effect.
570
+ * @since v0.9.1
571
+ */
572
+ ref(): this;
573
+ /**
574
+ * Calling `unref()` on a server will allow the program to exit if this is the only
575
+ * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
576
+ * @since v0.9.1
577
+ */
578
+ unref(): this;
579
+ /**
580
+ * Set this property to reject connections when the server's connection count gets
581
+ * high.
582
+ *
583
+ * It is not recommended to use this option once a socket has been sent to a child
584
+ * with `child_process.fork()`.
585
+ * @since v0.2.0
586
+ */
587
+ maxConnections: number;
588
+ connections: number;
589
+ /**
590
+ * Indicates whether or not the server is listening for connections.
591
+ * @since v5.7.0
592
+ */
593
+ listening: boolean;
594
+ /**
595
+ * events.EventEmitter
596
+ * 1. close
597
+ * 2. connection
598
+ * 3. error
599
+ * 4. listening
600
+ * 5. drop
601
+ */
602
+ addListener(event: string, listener: (...args: any[]) => void): this;
603
+ addListener(event: 'close', listener: () => void): this;
604
+ addListener(event: 'connection', listener: (socket: Socket) => void): this;
605
+ addListener(event: 'error', listener: (err: Error) => void): this;
606
+ addListener(event: 'listening', listener: () => void): this;
607
+ addListener(event: 'drop', listener: (data?: DropArgument) => void): this;
608
+ emit(event: string | symbol, ...args: any[]): boolean;
609
+ emit(event: 'close'): boolean;
610
+ emit(event: 'connection', socket: Socket): boolean;
611
+ emit(event: 'error', err: Error): boolean;
612
+ emit(event: 'listening'): boolean;
613
+ emit(event: 'drop', data?: DropArgument): boolean;
614
+ on(event: string, listener: (...args: any[]) => void): this;
615
+ on(event: 'close', listener: () => void): this;
616
+ on(event: 'connection', listener: (socket: Socket) => void): this;
617
+ on(event: 'error', listener: (err: Error) => void): this;
618
+ on(event: 'listening', listener: () => void): this;
619
+ on(event: 'drop', listener: (data?: DropArgument) => void): this;
620
+ once(event: string, listener: (...args: any[]) => void): this;
621
+ once(event: 'close', listener: () => void): this;
622
+ once(event: 'connection', listener: (socket: Socket) => void): this;
623
+ once(event: 'error', listener: (err: Error) => void): this;
624
+ once(event: 'listening', listener: () => void): this;
625
+ once(event: 'drop', listener: (data?: DropArgument) => void): this;
626
+ prependListener(event: string, listener: (...args: any[]) => void): this;
627
+ prependListener(event: 'close', listener: () => void): this;
628
+ prependListener(event: 'connection', listener: (socket: Socket) => void): this;
629
+ prependListener(event: 'error', listener: (err: Error) => void): this;
630
+ prependListener(event: 'listening', listener: () => void): this;
631
+ prependListener(event: 'drop', listener: (data?: DropArgument) => void): this;
632
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
633
+ prependOnceListener(event: 'close', listener: () => void): this;
634
+ prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
635
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
636
+ prependOnceListener(event: 'listening', listener: () => void): this;
637
+ prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
638
+ }
639
+ type IPVersion = 'ipv4' | 'ipv6';
640
+ /**
641
+ * The `BlockList` object can be used with some network APIs to specify rules for
642
+ * disabling inbound or outbound access to specific IP addresses, IP ranges, or
643
+ * IP subnets.
644
+ * @since v15.0.0, v14.18.0
645
+ */
646
+ class BlockList {
647
+ /**
648
+ * Adds a rule to block the given IP address.
649
+ * @since v15.0.0, v14.18.0
650
+ * @param address An IPv4 or IPv6 address.
651
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
652
+ */
653
+ addAddress(address: string, type?: IPVersion): void;
654
+ addAddress(address: SocketAddress): void;
655
+ /**
656
+ * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
657
+ * @since v15.0.0, v14.18.0
658
+ * @param start The starting IPv4 or IPv6 address in the range.
659
+ * @param end The ending IPv4 or IPv6 address in the range.
660
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
661
+ */
662
+ addRange(start: string, end: string, type?: IPVersion): void;
663
+ addRange(start: SocketAddress, end: SocketAddress): void;
664
+ /**
665
+ * Adds a rule to block a range of IP addresses specified as a subnet mask.
666
+ * @since v15.0.0, v14.18.0
667
+ * @param net The network IPv4 or IPv6 address.
668
+ * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
669
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
670
+ */
671
+ addSubnet(net: SocketAddress, prefix: number): void;
672
+ addSubnet(net: string, prefix: number, type?: IPVersion): void;
673
+ /**
674
+ * Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
675
+ *
676
+ * ```js
677
+ * const blockList = new net.BlockList();
678
+ * blockList.addAddress('123.123.123.123');
679
+ * blockList.addRange('10.0.0.1', '10.0.0.10');
680
+ * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
681
+ *
682
+ * console.log(blockList.check('123.123.123.123')); // Prints: true
683
+ * console.log(blockList.check('10.0.0.3')); // Prints: true
684
+ * console.log(blockList.check('222.111.111.222')); // Prints: false
685
+ *
686
+ * // IPv6 notation for IPv4 addresses works:
687
+ * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
688
+ * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
689
+ * ```
690
+ * @since v15.0.0, v14.18.0
691
+ * @param address The IP address to check
692
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
693
+ */
694
+ check(address: SocketAddress): boolean;
695
+ check(address: string, type?: IPVersion): boolean;
696
+ }
697
+ interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
698
+ timeout?: number | undefined;
699
+ }
700
+ interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
701
+ timeout?: number | undefined;
702
+ }
703
+ type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
704
+ /**
705
+ * Creates a new TCP or `IPC` server.
706
+ *
707
+ * If `allowHalfOpen` is set to `true`, when the other end of the socket
708
+ * signals the end of transmission, the server will only send back the end of
709
+ * transmission when `socket.end()` is explicitly called. For example, in the
710
+ * context of TCP, when a FIN packed is received, a FIN packed is sent
711
+ * back only when `socket.end()` is explicitly called. Until then the
712
+ * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
713
+ *
714
+ * If `pauseOnConnect` is set to `true`, then the socket associated with each
715
+ * incoming connection will be paused, and no data will be read from its handle.
716
+ * This allows connections to be passed between processes without any data being
717
+ * read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
718
+ *
719
+ * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
720
+ *
721
+ * Here is an example of a TCP echo server which listens for connections
722
+ * on port 8124:
723
+ *
724
+ * ```js
725
+ * const net = require('net');
726
+ * const server = net.createServer((c) => {
727
+ * // 'connection' listener.
728
+ * console.log('client connected');
729
+ * c.on('end', () => {
730
+ * console.log('client disconnected');
731
+ * });
732
+ * c.write('hello\r\n');
733
+ * c.pipe(c);
734
+ * });
735
+ * server.on('error', (err) => {
736
+ * throw err;
737
+ * });
738
+ * server.listen(8124, () => {
739
+ * console.log('server bound');
740
+ * });
741
+ * ```
742
+ *
743
+ * Test this by using `telnet`:
744
+ *
745
+ * ```console
746
+ * $ telnet localhost 8124
747
+ * ```
748
+ *
749
+ * To listen on the socket `/tmp/echo.sock`:
750
+ *
751
+ * ```js
752
+ * server.listen('/tmp/echo.sock', () => {
753
+ * console.log('server bound');
754
+ * });
755
+ * ```
756
+ *
757
+ * Use `nc` to connect to a Unix domain socket server:
758
+ *
759
+ * ```console
760
+ * $ nc -U /tmp/echo.sock
761
+ * ```
762
+ * @since v0.5.0
763
+ * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
764
+ */
765
+ function createServer(connectionListener?: (socket: Socket) => void): Server;
766
+ function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
767
+ /**
768
+ * Aliases to {@link createConnection}.
769
+ *
770
+ * Possible signatures:
771
+ *
772
+ * * {@link connect}
773
+ * * {@link connect} for `IPC` connections.
774
+ * * {@link connect} for TCP connections.
775
+ */
776
+ function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
777
+ function connect(port: number, host?: string, connectionListener?: () => void): Socket;
778
+ function connect(path: string, connectionListener?: () => void): Socket;
779
+ /**
780
+ * A factory function, which creates a new {@link Socket},
781
+ * immediately initiates connection with `socket.connect()`,
782
+ * then returns the `net.Socket` that starts the connection.
783
+ *
784
+ * When the connection is established, a `'connect'` event will be emitted
785
+ * on the returned socket. The last parameter `connectListener`, if supplied,
786
+ * will be added as a listener for the `'connect'` event **once**.
787
+ *
788
+ * Possible signatures:
789
+ *
790
+ * * {@link createConnection}
791
+ * * {@link createConnection} for `IPC` connections.
792
+ * * {@link createConnection} for TCP connections.
793
+ *
794
+ * The {@link connect} function is an alias to this function.
795
+ */
796
+ function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
797
+ function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
798
+ function createConnection(path: string, connectionListener?: () => void): Socket;
799
+ /**
800
+ * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
801
+ * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
802
+ *
803
+ * ```js
804
+ * net.isIP('::1'); // returns 6
805
+ * net.isIP('127.0.0.1'); // returns 4
806
+ * net.isIP('127.000.000.001'); // returns 0
807
+ * net.isIP('127.0.0.1/24'); // returns 0
808
+ * net.isIP('fhqwhgads'); // returns 0
809
+ * ```
810
+ * @since v0.3.0
811
+ */
812
+ function isIP(input: string): number;
813
+ /**
814
+ * Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
815
+ * leading zeroes. Otherwise, returns `false`.
816
+ *
817
+ * ```js
818
+ * net.isIPv4('127.0.0.1'); // returns true
819
+ * net.isIPv4('127.000.000.001'); // returns false
820
+ * net.isIPv4('127.0.0.1/24'); // returns false
821
+ * net.isIPv4('fhqwhgads'); // returns false
822
+ * ```
823
+ * @since v0.3.0
824
+ */
825
+ function isIPv4(input: string): boolean;
826
+ /**
827
+ * Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
828
+ *
829
+ * ```js
830
+ * net.isIPv6('::1'); // returns true
831
+ * net.isIPv6('fhqwhgads'); // returns false
832
+ * ```
833
+ * @since v0.3.0
834
+ */
835
+ function isIPv6(input: string): boolean;
836
+ interface SocketAddressInitOptions {
837
+ /**
838
+ * The network address as either an IPv4 or IPv6 string.
839
+ * @default 127.0.0.1
840
+ */
841
+ address?: string | undefined;
842
+ /**
843
+ * @default `'ipv4'`
844
+ */
845
+ family?: IPVersion | undefined;
846
+ /**
847
+ * An IPv6 flow-label used only if `family` is `'ipv6'`.
848
+ * @default 0
849
+ */
850
+ flowlabel?: number | undefined;
851
+ /**
852
+ * An IP port.
853
+ * @default 0
854
+ */
855
+ port?: number | undefined;
856
+ }
857
+ /**
858
+ * @since v15.14.0, v14.18.0
859
+ */
860
+ class SocketAddress {
861
+ constructor(options: SocketAddressInitOptions);
862
+ /**
863
+ * @since v15.14.0, v14.18.0
864
+ */
865
+ readonly address: string;
866
+ /**
867
+ * Either \`'ipv4'\` or \`'ipv6'\`.
868
+ * @since v15.14.0, v14.18.0
869
+ */
870
+ readonly family: IPVersion;
871
+ /**
872
+ * @since v15.14.0, v14.18.0
873
+ */
874
+ readonly port: number;
875
+ /**
876
+ * @since v15.14.0, v14.18.0
877
+ */
878
+ readonly flowlabel: number;
879
+ }
880
+ }
881
+ declare module 'node:net' {
882
+ export * from 'net';
883
+ }
node_modules/@types/node/os.d.ts ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * The `os` module provides operating system-related utility methods and
3
+ * properties. It can be accessed using:
4
+ *
5
+ * ```js
6
+ * const os = require('os');
7
+ * ```
8
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js)
9
+ */
10
+ declare module 'os' {
11
+ interface CpuInfo {
12
+ model: string;
13
+ speed: number;
14
+ times: {
15
+ user: number;
16
+ nice: number;
17
+ sys: number;
18
+ idle: number;
19
+ irq: number;
20
+ };
21
+ }
22
+ interface NetworkInterfaceBase {
23
+ address: string;
24
+ netmask: string;
25
+ mac: string;
26
+ internal: boolean;
27
+ cidr: string | null;
28
+ }
29
+ interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
30
+ family: 'IPv4';
31
+ scopeid?: undefined;
32
+ }
33
+ interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
34
+ family: 'IPv6';
35
+ scopeid: number;
36
+ }
37
+ interface UserInfo<T> {
38
+ username: T;
39
+ uid: number;
40
+ gid: number;
41
+ shell: T;
42
+ homedir: T;
43
+ }
44
+ type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
45
+ /**
46
+ * Returns the host name of the operating system as a string.
47
+ * @since v0.3.3
48
+ */
49
+ function hostname(): string;
50
+ /**
51
+ * Returns an array containing the 1, 5, and 15 minute load averages.
52
+ *
53
+ * The load average is a measure of system activity calculated by the operating
54
+ * system and expressed as a fractional number.
55
+ *
56
+ * The load average is a Unix-specific concept. On Windows, the return value is
57
+ * always `[0, 0, 0]`.
58
+ * @since v0.3.3
59
+ */
60
+ function loadavg(): number[];
61
+ /**
62
+ * Returns the system uptime in number of seconds.
63
+ * @since v0.3.3
64
+ */
65
+ function uptime(): number;
66
+ /**
67
+ * Returns the amount of free system memory in bytes as an integer.
68
+ * @since v0.3.3
69
+ */
70
+ function freemem(): number;
71
+ /**
72
+ * Returns the total amount of system memory in bytes as an integer.
73
+ * @since v0.3.3
74
+ */
75
+ function totalmem(): number;
76
+ /**
77
+ * Returns an array of objects containing information about each logical CPU core.
78
+ *
79
+ * The properties included on each object include:
80
+ *
81
+ * ```js
82
+ * [
83
+ * {
84
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
85
+ * speed: 2926,
86
+ * times: {
87
+ * user: 252020,
88
+ * nice: 0,
89
+ * sys: 30340,
90
+ * idle: 1070356870,
91
+ * irq: 0
92
+ * }
93
+ * },
94
+ * {
95
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
96
+ * speed: 2926,
97
+ * times: {
98
+ * user: 306960,
99
+ * nice: 0,
100
+ * sys: 26980,
101
+ * idle: 1071569080,
102
+ * irq: 0
103
+ * }
104
+ * },
105
+ * {
106
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
107
+ * speed: 2926,
108
+ * times: {
109
+ * user: 248450,
110
+ * nice: 0,
111
+ * sys: 21750,
112
+ * idle: 1070919370,
113
+ * irq: 0
114
+ * }
115
+ * },
116
+ * {
117
+ * model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
118
+ * speed: 2926,
119
+ * times: {
120
+ * user: 256880,
121
+ * nice: 0,
122
+ * sys: 19430,
123
+ * idle: 1070905480,
124
+ * irq: 20
125
+ * }
126
+ * },
127
+ * ]
128
+ * ```
129
+ *
130
+ * `nice` values are POSIX-only. On Windows, the `nice` values of all processors
131
+ * are always 0.
132
+ * @since v0.3.3
133
+ */
134
+ function cpus(): CpuInfo[];
135
+ /**
136
+ * Returns an estimate of the default amount of parallelism a program should use. Always returns a value greater than zero.
137
+ *
138
+ * This function is a small wrapper about libuv's [`uv_available_parallelism()`](https://docs.libuv.org/en/v1.x/misc.html#c.uv_available_parallelism).
139
+ * @since 18.4.0
140
+ */
141
+ function availableParallelism(): number;
142
+ /**
143
+ * Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
144
+ * returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
145
+ *
146
+ * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
147
+ * about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
148
+ * @since v0.3.3
149
+ */
150
+ function type(): string;
151
+ /**
152
+ * Returns the operating system as a string.
153
+ *
154
+ * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See
155
+ * [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
156
+ * @since v0.3.3
157
+ */
158
+ function release(): string;
159
+ /**
160
+ * Returns an object containing network interfaces that have been assigned a
161
+ * network address.
162
+ *
163
+ * Each key on the returned object identifies a network interface. The associated
164
+ * value is an array of objects that each describe an assigned network address.
165
+ *
166
+ * The properties available on the assigned network address object include:
167
+ *
168
+ * ```js
169
+ * {
170
+ * lo: [
171
+ * {
172
+ * address: '127.0.0.1',
173
+ * netmask: '255.0.0.0',
174
+ * family: 'IPv4',
175
+ * mac: '00:00:00:00:00:00',
176
+ * internal: true,
177
+ * cidr: '127.0.0.1/8'
178
+ * },
179
+ * {
180
+ * address: '::1',
181
+ * netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
182
+ * family: 'IPv6',
183
+ * mac: '00:00:00:00:00:00',
184
+ * scopeid: 0,
185
+ * internal: true,
186
+ * cidr: '::1/128'
187
+ * }
188
+ * ],
189
+ * eth0: [
190
+ * {
191
+ * address: '192.168.1.108',
192
+ * netmask: '255.255.255.0',
193
+ * family: 'IPv4',
194
+ * mac: '01:02:03:0a:0b:0c',
195
+ * internal: false,
196
+ * cidr: '192.168.1.108/24'
197
+ * },
198
+ * {
199
+ * address: 'fe80::a00:27ff:fe4e:66a1',
200
+ * netmask: 'ffff:ffff:ffff:ffff::',
201
+ * family: 'IPv6',
202
+ * mac: '01:02:03:0a:0b:0c',
203
+ * scopeid: 1,
204
+ * internal: false,
205
+ * cidr: 'fe80::a00:27ff:fe4e:66a1/64'
206
+ * }
207
+ * ]
208
+ * }
209
+ * ```
210
+ * @since v0.6.0
211
+ */
212
+ function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
213
+ /**
214
+ * Returns the string path of the current user's home directory.
215
+ *
216
+ * On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
217
+ * uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
218
+ *
219
+ * On Windows, it uses the `USERPROFILE` environment variable if defined.
220
+ * Otherwise it uses the path to the profile directory of the current user.
221
+ * @since v2.3.0
222
+ */
223
+ function homedir(): string;
224
+ /**
225
+ * Returns information about the currently effective user. On POSIX platforms,
226
+ * this is typically a subset of the password file. The returned object includes
227
+ * the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`.
228
+ *
229
+ * The value of `homedir` returned by `os.userInfo()` is provided by the operating
230
+ * system. This differs from the result of `os.homedir()`, which queries
231
+ * environment variables for the home directory before falling back to the
232
+ * operating system response.
233
+ *
234
+ * Throws a `SystemError` if a user has no `username` or `homedir`.
235
+ * @since v6.0.0
236
+ */
237
+ function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
238
+ function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
239
+ type SignalConstants = {
240
+ [key in NodeJS.Signals]: number;
241
+ };
242
+ namespace constants {
243
+ const UV_UDP_REUSEADDR: number;
244
+ namespace signals {}
245
+ const signals: SignalConstants;
246
+ namespace errno {
247
+ const E2BIG: number;
248
+ const EACCES: number;
249
+ const EADDRINUSE: number;
250
+ const EADDRNOTAVAIL: number;
251
+ const EAFNOSUPPORT: number;
252
+ const EAGAIN: number;
253
+ const EALREADY: number;
254
+ const EBADF: number;
255
+ const EBADMSG: number;
256
+ const EBUSY: number;
257
+ const ECANCELED: number;
258
+ const ECHILD: number;
259
+ const ECONNABORTED: number;
260
+ const ECONNREFUSED: number;
261
+ const ECONNRESET: number;
262
+ const EDEADLK: number;
263
+ const EDESTADDRREQ: number;
264
+ const EDOM: number;
265
+ const EDQUOT: number;
266
+ const EEXIST: number;
267
+ const EFAULT: number;
268
+ const EFBIG: number;
269
+ const EHOSTUNREACH: number;
270
+ const EIDRM: number;
271
+ const EILSEQ: number;
272
+ const EINPROGRESS: number;
273
+ const EINTR: number;
274
+ const EINVAL: number;
275
+ const EIO: number;
276
+ const EISCONN: number;
277
+ const EISDIR: number;
278
+ const ELOOP: number;
279
+ const EMFILE: number;
280
+ const EMLINK: number;
281
+ const EMSGSIZE: number;
282
+ const EMULTIHOP: number;
283
+ const ENAMETOOLONG: number;
284
+ const ENETDOWN: number;
285
+ const ENETRESET: number;
286
+ const ENETUNREACH: number;
287
+ const ENFILE: number;
288
+ const ENOBUFS: number;
289
+ const ENODATA: number;
290
+ const ENODEV: number;
291
+ const ENOENT: number;
292
+ const ENOEXEC: number;
293
+ const ENOLCK: number;
294
+ const ENOLINK: number;
295
+ const ENOMEM: number;
296
+ const ENOMSG: number;
297
+ const ENOPROTOOPT: number;
298
+ const ENOSPC: number;
299
+ const ENOSR: number;
300
+ const ENOSTR: number;
301
+ const ENOSYS: number;
302
+ const ENOTCONN: number;
303
+ const ENOTDIR: number;
304
+ const ENOTEMPTY: number;
305
+ const ENOTSOCK: number;
306
+ const ENOTSUP: number;
307
+ const ENOTTY: number;
308
+ const ENXIO: number;
309
+ const EOPNOTSUPP: number;
310
+ const EOVERFLOW: number;
311
+ const EPERM: number;
312
+ const EPIPE: number;
313
+ const EPROTO: number;
314
+ const EPROTONOSUPPORT: number;
315
+ const EPROTOTYPE: number;
316
+ const ERANGE: number;
317
+ const EROFS: number;
318
+ const ESPIPE: number;
319
+ const ESRCH: number;
320
+ const ESTALE: number;
321
+ const ETIME: number;
322
+ const ETIMEDOUT: number;
323
+ const ETXTBSY: number;
324
+ const EWOULDBLOCK: number;
325
+ const EXDEV: number;
326
+ const WSAEINTR: number;
327
+ const WSAEBADF: number;
328
+ const WSAEACCES: number;
329
+ const WSAEFAULT: number;
330
+ const WSAEINVAL: number;
331
+ const WSAEMFILE: number;
332
+ const WSAEWOULDBLOCK: number;
333
+ const WSAEINPROGRESS: number;
334
+ const WSAEALREADY: number;
335
+ const WSAENOTSOCK: number;
336
+ const WSAEDESTADDRREQ: number;
337
+ const WSAEMSGSIZE: number;
338
+ const WSAEPROTOTYPE: number;
339
+ const WSAENOPROTOOPT: number;
340
+ const WSAEPROTONOSUPPORT: number;
341
+ const WSAESOCKTNOSUPPORT: number;
342
+ const WSAEOPNOTSUPP: number;
343
+ const WSAEPFNOSUPPORT: number;
344
+ const WSAEAFNOSUPPORT: number;
345
+ const WSAEADDRINUSE: number;
346
+ const WSAEADDRNOTAVAIL: number;
347
+ const WSAENETDOWN: number;
348
+ const WSAENETUNREACH: number;
349
+ const WSAENETRESET: number;
350
+ const WSAECONNABORTED: number;
351
+ const WSAECONNRESET: number;
352
+ const WSAENOBUFS: number;
353
+ const WSAEISCONN: number;
354
+ const WSAENOTCONN: number;
355
+ const WSAESHUTDOWN: number;
356
+ const WSAETOOMANYREFS: number;
357
+ const WSAETIMEDOUT: number;
358
+ const WSAECONNREFUSED: number;
359
+ const WSAELOOP: number;
360
+ const WSAENAMETOOLONG: number;
361
+ const WSAEHOSTDOWN: number;
362
+ const WSAEHOSTUNREACH: number;
363
+ const WSAENOTEMPTY: number;
364
+ const WSAEPROCLIM: number;
365
+ const WSAEUSERS: number;
366
+ const WSAEDQUOT: number;
367
+ const WSAESTALE: number;
368
+ const WSAEREMOTE: number;
369
+ const WSASYSNOTREADY: number;
370
+ const WSAVERNOTSUPPORTED: number;
371
+ const WSANOTINITIALISED: number;
372
+ const WSAEDISCON: number;
373
+ const WSAENOMORE: number;
374
+ const WSAECANCELLED: number;
375
+ const WSAEINVALIDPROCTABLE: number;
376
+ const WSAEINVALIDPROVIDER: number;
377
+ const WSAEPROVIDERFAILEDINIT: number;
378
+ const WSASYSCALLFAILURE: number;
379
+ const WSASERVICE_NOT_FOUND: number;
380
+ const WSATYPE_NOT_FOUND: number;
381
+ const WSA_E_NO_MORE: number;
382
+ const WSA_E_CANCELLED: number;
383
+ const WSAEREFUSED: number;
384
+ }
385
+ namespace priority {
386
+ const PRIORITY_LOW: number;
387
+ const PRIORITY_BELOW_NORMAL: number;
388
+ const PRIORITY_NORMAL: number;
389
+ const PRIORITY_ABOVE_NORMAL: number;
390
+ const PRIORITY_HIGH: number;
391
+ const PRIORITY_HIGHEST: number;
392
+ }
393
+ }
394
+ const devNull: string;
395
+ const EOL: string;
396
+ /**
397
+ * Returns the operating system CPU architecture for which the Node.js binary was
398
+ * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
399
+ *
400
+ * The return value is equivalent to `process.arch`.
401
+ * @since v0.5.0
402
+ */
403
+ function arch(): string;
404
+ /**
405
+ * Returns a string identifying the kernel version.
406
+ *
407
+ * On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
408
+ * available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
409
+ * @since v13.11.0, v12.17.0
410
+ */
411
+ function version(): string;
412
+ /**
413
+ * Returns a string identifying the operating system platform for which
414
+ * the Node.js binary was compiled. The value is set at compile time.
415
+ * Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,`'openbsd'`, `'sunos'`, and `'win32'`.
416
+ *
417
+ * The return value is equivalent to `process.platform`.
418
+ *
419
+ * The value `'android'` may also be returned if Node.js is built on the Android
420
+ * operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
421
+ * @since v0.5.0
422
+ */
423
+ function platform(): NodeJS.Platform;
424
+ /**
425
+ * Returns the machine type as a string, such as arm, aarch64, mips, mips64, ppc64, ppc64le, s390, s390x, i386, i686, x86_64.
426
+ *
427
+ * On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname).
428
+ * On Windows, `RtlGetVersion()` is used, and if it is not available, `GetVersionExW()` will be used.
429
+ * See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
430
+ * @since v18.9.0
431
+ */
432
+ function machine(): string;
433
+ /**
434
+ * Returns the operating system's default directory for temporary files as a
435
+ * string.
436
+ * @since v0.9.9
437
+ */
438
+ function tmpdir(): string;
439
+ /**
440
+ * Returns a string identifying the endianness of the CPU for which the Node.js
441
+ * binary was compiled.
442
+ *
443
+ * Possible values are `'BE'` for big endian and `'LE'` for little endian.
444
+ * @since v0.9.4
445
+ */
446
+ function endianness(): 'BE' | 'LE';
447
+ /**
448
+ * Returns the scheduling priority for the process specified by `pid`. If `pid` is
449
+ * not provided or is `0`, the priority of the current process is returned.
450
+ * @since v10.10.0
451
+ * @param [pid=0] The process ID to retrieve scheduling priority for.
452
+ */
453
+ function getPriority(pid?: number): number;
454
+ /**
455
+ * Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used.
456
+ *
457
+ * The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows
458
+ * priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range
459
+ * mapping may cause the return value to be slightly different on Windows. To avoid
460
+ * confusion, set `priority` to one of the priority constants.
461
+ *
462
+ * On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
463
+ * privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`.
464
+ * @since v10.10.0
465
+ * @param [pid=0] The process ID to set scheduling priority for.
466
+ * @param priority The scheduling priority to assign to the process.
467
+ */
468
+ function setPriority(priority: number): void;
469
+ function setPriority(pid: number, priority: number): void;
470
+ }
471
+ declare module 'node:os' {
472
+ export * from 'os';
473
+ }
node_modules/@types/node/package.json ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from": "@types/node@>=10.0.0",
3
+ "_id": "@types/[email protected]",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-z6nr0TTEOBGkzLGmbypWOGnpSpSIBorEhC4L+4HeQ2iezKCi4f77kyslRwvHeNitymGQ+oFyIWGP96l/DPSV9w==",
6
+ "_location": "/@types/node",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "range",
10
+ "registry": true,
11
+ "raw": "@types/node@>=10.0.0",
12
+ "name": "@types/node",
13
+ "escapedName": "@types%2fnode",
14
+ "scope": "@types",
15
+ "rawSpec": ">=10.0.0",
16
+ "saveSpec": null,
17
+ "fetchSpec": ">=10.0.0"
18
+ },
19
+ "_requiredBy": [
20
+ "/@types/cors",
21
+ "/engine.io"
22
+ ],
23
+ "_resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.0.tgz",
24
+ "_shasum": "286a65e3fdffd691e170541e6ecb0410b16a38be",
25
+ "_spec": "@types/node@>=10.0.0",
26
+ "_where": "/Users/sylvainfiloni/Documents/HF spaces/Docker test/controlnet anim/controlnet-animation-doodle/node_modules/engine.io",
27
+ "bugs": {
28
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
29
+ },
30
+ "bundleDependencies": false,
31
+ "contributors": [
32
+ {
33
+ "name": "Microsoft TypeScript",
34
+ "url": "https://github.com/Microsoft"
35
+ },
36
+ {
37
+ "name": "DefinitelyTyped",
38
+ "url": "https://github.com/DefinitelyTyped"
39
+ },
40
+ {
41
+ "name": "Alberto Schiabel",
42
+ "url": "https://github.com/jkomyno"
43
+ },
44
+ {
45
+ "name": "Alvis HT Tang",
46
+ "url": "https://github.com/alvis"
47
+ },
48
+ {
49
+ "name": "Andrew Makarov",
50
+ "url": "https://github.com/r3nya"
51
+ },
52
+ {
53
+ "name": "Benjamin Toueg",
54
+ "url": "https://github.com/btoueg"
55
+ },
56
+ {
57
+ "name": "Chigozirim C.",
58
+ "url": "https://github.com/smac89"
59
+ },
60
+ {
61
+ "name": "David Junger",
62
+ "url": "https://github.com/touffy"
63
+ },
64
+ {
65
+ "name": "Deividas Bakanas",
66
+ "url": "https://github.com/DeividasBakanas"
67
+ },
68
+ {
69
+ "name": "Eugene Y. Q. Shen",
70
+ "url": "https://github.com/eyqs"
71
+ },
72
+ {
73
+ "name": "Hannes Magnusson",
74
+ "url": "https://github.com/Hannes-Magnusson-CK"
75
+ },
76
+ {
77
+ "name": "Huw",
78
+ "url": "https://github.com/hoo29"
79
+ },
80
+ {
81
+ "name": "Kelvin Jin",
82
+ "url": "https://github.com/kjin"
83
+ },
84
+ {
85
+ "name": "Klaus Meinhardt",
86
+ "url": "https://github.com/ajafff"
87
+ },
88
+ {
89
+ "name": "Lishude",
90
+ "url": "https://github.com/islishude"
91
+ },
92
+ {
93
+ "name": "Mariusz Wiktorczyk",
94
+ "url": "https://github.com/mwiktorczyk"
95
+ },
96
+ {
97
+ "name": "Mohsen Azimi",
98
+ "url": "https://github.com/mohsen1"
99
+ },
100
+ {
101
+ "name": "Nicolas Even",
102
+ "url": "https://github.com/n-e"
103
+ },
104
+ {
105
+ "name": "Nikita Galkin",
106
+ "url": "https://github.com/galkin"
107
+ },
108
+ {
109
+ "name": "Parambir Singh",
110
+ "url": "https://github.com/parambirs"
111
+ },
112
+ {
113
+ "name": "Sebastian Silbermann",
114
+ "url": "https://github.com/eps1lon"
115
+ },
116
+ {
117
+ "name": "Simon Schick",
118
+ "url": "https://github.com/SimonSchick"
119
+ },
120
+ {
121
+ "name": "Thomas den Hollander",
122
+ "url": "https://github.com/ThomasdenH"
123
+ },
124
+ {
125
+ "name": "Wilco Bakker",
126
+ "url": "https://github.com/WilcoBakker"
127
+ },
128
+ {
129
+ "name": "wwwy3y3",
130
+ "url": "https://github.com/wwwy3y3"
131
+ },
132
+ {
133
+ "name": "Samuel Ainsworth",
134
+ "url": "https://github.com/samuela"
135
+ },
136
+ {
137
+ "name": "Kyle Uehlein",
138
+ "url": "https://github.com/kuehlein"
139
+ },
140
+ {
141
+ "name": "Thanik Bhongbhibhat",
142
+ "url": "https://github.com/bhongy"
143
+ },
144
+ {
145
+ "name": "Marcin Kopacz",
146
+ "url": "https://github.com/chyzwar"
147
+ },
148
+ {
149
+ "name": "Trivikram Kamat",
150
+ "url": "https://github.com/trivikr"
151
+ },
152
+ {
153
+ "name": "Junxiao Shi",
154
+ "url": "https://github.com/yoursunny"
155
+ },
156
+ {
157
+ "name": "Ilia Baryshnikov",
158
+ "url": "https://github.com/qwelias"
159
+ },
160
+ {
161
+ "name": "ExE Boss",
162
+ "url": "https://github.com/ExE-Boss"
163
+ },
164
+ {
165
+ "name": "Piotr Błażejewicz",
166
+ "url": "https://github.com/peterblazejewicz"
167
+ },
168
+ {
169
+ "name": "Anna Henningsen",
170
+ "url": "https://github.com/addaleax"
171
+ },
172
+ {
173
+ "name": "Victor Perin",
174
+ "url": "https://github.com/victorperin"
175
+ },
176
+ {
177
+ "name": "Yongsheng Zhang",
178
+ "url": "https://github.com/ZYSzys"
179
+ },
180
+ {
181
+ "name": "NodeJS Contributors",
182
+ "url": "https://github.com/NodeJS"
183
+ },
184
+ {
185
+ "name": "Linus Unnebäck",
186
+ "url": "https://github.com/LinusU"
187
+ },
188
+ {
189
+ "name": "wafuwafu13",
190
+ "url": "https://github.com/wafuwafu13"
191
+ },
192
+ {
193
+ "name": "Matteo Collina",
194
+ "url": "https://github.com/mcollina"
195
+ },
196
+ {
197
+ "name": "Dmitry Semigradsky",
198
+ "url": "https://github.com/Semigradsky"
199
+ }
200
+ ],
201
+ "dependencies": {},
202
+ "deprecated": false,
203
+ "description": "TypeScript definitions for Node.js",
204
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
205
+ "license": "MIT",
206
+ "main": "",
207
+ "name": "@types/node",
208
+ "repository": {
209
+ "type": "git",
210
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git",
211
+ "directory": "types/node"
212
+ },
213
+ "scripts": {},
214
+ "typeScriptVersion": "4.2",
215
+ "types": "index.d.ts",
216
+ "typesPublisherContentHash": "18d99f309cf54ef71944b4f8cab770334defff1d97894154f8c301b78637539f",
217
+ "typesVersions": {
218
+ "<=4.8": {
219
+ "*": [
220
+ "ts4.8/*"
221
+ ]
222
+ }
223
+ },
224
+ "version": "18.15.0"
225
+ }
node_modules/@types/node/path.d.ts ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ declare module 'path/posix' {
2
+ import path = require('path');
3
+ export = path;
4
+ }
5
+ declare module 'path/win32' {
6
+ import path = require('path');
7
+ export = path;
8
+ }
9
+ /**
10
+ * The `path` module provides utilities for working with file and directory paths.
11
+ * It can be accessed using:
12
+ *
13
+ * ```js
14
+ * const path = require('path');
15
+ * ```
16
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/path.js)
17
+ */
18
+ declare module 'path' {
19
+ namespace path {
20
+ /**
21
+ * A parsed path object generated by path.parse() or consumed by path.format().
22
+ */
23
+ interface ParsedPath {
24
+ /**
25
+ * The root of the path such as '/' or 'c:\'
26
+ */
27
+ root: string;
28
+ /**
29
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
30
+ */
31
+ dir: string;
32
+ /**
33
+ * The file name including extension (if any) such as 'index.html'
34
+ */
35
+ base: string;
36
+ /**
37
+ * The file extension (if any) such as '.html'
38
+ */
39
+ ext: string;
40
+ /**
41
+ * The file name without extension (if any) such as 'index'
42
+ */
43
+ name: string;
44
+ }
45
+ interface FormatInputPathObject {
46
+ /**
47
+ * The root of the path such as '/' or 'c:\'
48
+ */
49
+ root?: string | undefined;
50
+ /**
51
+ * The full directory path such as '/home/user/dir' or 'c:\path\dir'
52
+ */
53
+ dir?: string | undefined;
54
+ /**
55
+ * The file name including extension (if any) such as 'index.html'
56
+ */
57
+ base?: string | undefined;
58
+ /**
59
+ * The file extension (if any) such as '.html'
60
+ */
61
+ ext?: string | undefined;
62
+ /**
63
+ * The file name without extension (if any) such as 'index'
64
+ */
65
+ name?: string | undefined;
66
+ }
67
+ interface PlatformPath {
68
+ /**
69
+ * Normalize a string path, reducing '..' and '.' parts.
70
+ * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
71
+ *
72
+ * @param path string path to normalize.
73
+ * @throws {TypeError} if `path` is not a string.
74
+ */
75
+ normalize(path: string): string;
76
+ /**
77
+ * Join all arguments together and normalize the resulting path.
78
+ *
79
+ * @param paths paths to join.
80
+ * @throws {TypeError} if any of the path segments is not a string.
81
+ */
82
+ join(...paths: string[]): string;
83
+ /**
84
+ * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
85
+ *
86
+ * Starting from leftmost {from} parameter, resolves {to} to an absolute path.
87
+ *
88
+ * If {to} isn't already absolute, {from} arguments are prepended in right to left order,
89
+ * until an absolute path is found. If after using all {from} paths still no absolute path is found,
90
+ * the current working directory is used as well. The resulting path is normalized,
91
+ * and trailing slashes are removed unless the path gets resolved to the root directory.
92
+ *
93
+ * @param paths A sequence of paths or path segments.
94
+ * @throws {TypeError} if any of the arguments is not a string.
95
+ */
96
+ resolve(...paths: string[]): string;
97
+ /**
98
+ * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
99
+ *
100
+ * If the given {path} is a zero-length string, `false` will be returned.
101
+ *
102
+ * @param path path to test.
103
+ * @throws {TypeError} if `path` is not a string.
104
+ */
105
+ isAbsolute(path: string): boolean;
106
+ /**
107
+ * Solve the relative path from {from} to {to} based on the current working directory.
108
+ * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve.
109
+ *
110
+ * @throws {TypeError} if either `from` or `to` is not a string.
111
+ */
112
+ relative(from: string, to: string): string;
113
+ /**
114
+ * Return the directory name of a path. Similar to the Unix dirname command.
115
+ *
116
+ * @param path the path to evaluate.
117
+ * @throws {TypeError} if `path` is not a string.
118
+ */
119
+ dirname(path: string): string;
120
+ /**
121
+ * Return the last portion of a path. Similar to the Unix basename command.
122
+ * Often used to extract the file name from a fully qualified path.
123
+ *
124
+ * @param path the path to evaluate.
125
+ * @param suffix optionally, an extension to remove from the result.
126
+ * @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string.
127
+ */
128
+ basename(path: string, suffix?: string): string;
129
+ /**
130
+ * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
131
+ * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
132
+ *
133
+ * @param path the path to evaluate.
134
+ * @throws {TypeError} if `path` is not a string.
135
+ */
136
+ extname(path: string): string;
137
+ /**
138
+ * The platform-specific file separator. '\\' or '/'.
139
+ */
140
+ readonly sep: '\\' | '/';
141
+ /**
142
+ * The platform-specific file delimiter. ';' or ':'.
143
+ */
144
+ readonly delimiter: ';' | ':';
145
+ /**
146
+ * Returns an object from a path string - the opposite of format().
147
+ *
148
+ * @param path path to evaluate.
149
+ * @throws {TypeError} if `path` is not a string.
150
+ */
151
+ parse(path: string): ParsedPath;
152
+ /**
153
+ * Returns a path string from an object - the opposite of parse().
154
+ *
155
+ * @param pathObject path to evaluate.
156
+ */
157
+ format(pathObject: FormatInputPathObject): string;
158
+ /**
159
+ * On Windows systems only, returns an equivalent namespace-prefixed path for the given path.
160
+ * If path is not a string, path will be returned without modifications.
161
+ * This method is meaningful only on Windows system.
162
+ * On POSIX systems, the method is non-operational and always returns path without modifications.
163
+ */
164
+ toNamespacedPath(path: string): string;
165
+ /**
166
+ * Posix specific pathing.
167
+ * Same as parent object on posix.
168
+ */
169
+ readonly posix: PlatformPath;
170
+ /**
171
+ * Windows specific pathing.
172
+ * Same as parent object on windows
173
+ */
174
+ readonly win32: PlatformPath;
175
+ }
176
+ }
177
+ const path: path.PlatformPath;
178
+ export = path;
179
+ }
180
+ declare module 'node:path' {
181
+ import path = require('path');
182
+ export = path;
183
+ }
184
+ declare module 'node:path/posix' {
185
+ import path = require('path/posix');
186
+ export = path;
187
+ }
188
+ declare module 'node:path/win32' {
189
+ import path = require('path/win32');
190
+ export = path;
191
+ }