@idlebox/stripe-node-types 24.0.14 → 24.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/module.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ declare module "node:module" {
|
|
|
46
46
|
/**
|
|
47
47
|
* The following constants are returned as the `status` field in the object returned by
|
|
48
48
|
* {@link enableCompileCache} to indicate the result of the attempt to enable the
|
|
49
|
-
* [module compile cache](https://nodejs.org/docs/latest-
|
|
49
|
+
* [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
|
|
50
50
|
* @since v22.8.0
|
|
51
51
|
*/
|
|
52
52
|
namespace compileCacheStatus {
|
|
@@ -78,6 +78,24 @@ declare module "node:module" {
|
|
|
78
78
|
const DISABLED: number;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
interface EnableCompileCacheOptions {
|
|
82
|
+
/**
|
|
83
|
+
* Optional. Directory to store the compile cache. If not specified,
|
|
84
|
+
* the directory specified by the `NODE_COMPILE_CACHE=dir` environment variable
|
|
85
|
+
* will be used if it's set, or `path.join(os.tmpdir(), 'node-compile-cache')`
|
|
86
|
+
* otherwise.
|
|
87
|
+
* @since v25.0.0
|
|
88
|
+
*/
|
|
89
|
+
directory?: string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Optional. If `true`, enables portable compile cache so that
|
|
92
|
+
* the cache can be reused even if the project directory is moved. This is a best-effort
|
|
93
|
+
* feature. If not specified, it will depend on whether the environment variable
|
|
94
|
+
* `NODE_COMPILE_CACHE_PORTABLE=1` is set.
|
|
95
|
+
* @since v25.0.0
|
|
96
|
+
*/
|
|
97
|
+
portable?: boolean | undefined;
|
|
98
|
+
}
|
|
81
99
|
interface EnableCompileCacheResult {
|
|
82
100
|
/**
|
|
83
101
|
* One of the {@link constants.compileCacheStatus}
|
|
@@ -97,25 +115,21 @@ declare module "node:module" {
|
|
|
97
115
|
directory?: string;
|
|
98
116
|
}
|
|
99
117
|
/**
|
|
100
|
-
* Enable [module compile cache](https://nodejs.org/docs/latest-
|
|
118
|
+
* Enable [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
101
119
|
* in the current Node.js instance.
|
|
102
120
|
*
|
|
103
|
-
*
|
|
104
|
-
* `
|
|
105
|
-
* `
|
|
106
|
-
* recommended to call `module.enableCompileCache()` without specifying the `cacheDir`,
|
|
107
|
-
* so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
|
|
108
|
-
* variable when necessary.
|
|
121
|
+
* For general use cases, it's recommended to call `module.enableCompileCache()` without
|
|
122
|
+
* specifying the `options.directory`, so that the directory can be overridden by the
|
|
123
|
+
* `NODE_COMPILE_CACHE` environment variable when necessary.
|
|
109
124
|
*
|
|
110
|
-
* Since compile cache is supposed to be a
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* field in the returned object would be one of the `module.constants.compileCacheStatus`
|
|
125
|
+
* Since compile cache is supposed to be a optimization that is not mission critical, this
|
|
126
|
+
* method is designed to not throw any exception when the compile cache cannot be enabled.
|
|
127
|
+
* Instead, it will return an object containing an error message in the `message` field to
|
|
128
|
+
* aid debugging. If compile cache is enabled successfully, the `directory` field in the
|
|
129
|
+
* returned object contains the path to the directory where the compile cache is stored. The
|
|
130
|
+
* `status` field in the returned object would be one of the `module.constants.compileCacheStatus`
|
|
117
131
|
* values to indicate the result of the attempt to enable the
|
|
118
|
-
* [module compile cache](https://nodejs.org/docs/latest-
|
|
132
|
+
* [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
|
|
119
133
|
*
|
|
120
134
|
* This method only affects the current Node.js instance. To enable it in child worker threads,
|
|
121
135
|
* either call this method in child worker threads too, or set the
|
|
@@ -123,12 +137,11 @@ declare module "node:module" {
|
|
|
123
137
|
* be inherited into the child workers. The directory can be obtained either from the
|
|
124
138
|
* `directory` field returned by this method, or with {@link getCompileCacheDir}.
|
|
125
139
|
* @since v22.8.0
|
|
126
|
-
* @param
|
|
127
|
-
* will be stored/retrieved.
|
|
140
|
+
* @param options Optional. If a string is passed, it is considered to be `options.directory`.
|
|
128
141
|
*/
|
|
129
|
-
function enableCompileCache(
|
|
142
|
+
function enableCompileCache(options?: string | EnableCompileCacheOptions): EnableCompileCacheResult;
|
|
130
143
|
/**
|
|
131
|
-
* Flush the [module compile cache](https://nodejs.org/docs/latest-
|
|
144
|
+
* Flush the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
132
145
|
* accumulated from modules already loaded
|
|
133
146
|
* in the current Node.js instance to disk. This returns after all the flushing
|
|
134
147
|
* file system operations come to an end, no matter they succeed or not. If there
|
|
@@ -139,7 +152,7 @@ declare module "node:module" {
|
|
|
139
152
|
function flushCompileCache(): void;
|
|
140
153
|
/**
|
|
141
154
|
* @since v22.8.0
|
|
142
|
-
* @return Path to the [module compile cache](https://nodejs.org/docs/latest-
|
|
155
|
+
* @return Path to the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
|
|
143
156
|
* directory if it is enabled, or `undefined` otherwise.
|
|
144
157
|
*/
|
|
145
158
|
function getCompileCacheDir(): string | undefined;
|
|
@@ -210,7 +223,7 @@ declare module "node:module" {
|
|
|
210
223
|
*/
|
|
211
224
|
data?: Data | undefined;
|
|
212
225
|
/**
|
|
213
|
-
* [Transferable objects](https://nodejs.org/docs/latest-
|
|
226
|
+
* [Transferable objects](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#portpostmessagevalue-transferlist)
|
|
214
227
|
* to be passed into the `initialize` hook.
|
|
215
228
|
*/
|
|
216
229
|
transferList?: any[] | undefined;
|
|
@@ -219,10 +232,10 @@ declare module "node:module" {
|
|
|
219
232
|
/**
|
|
220
233
|
* Register a module that exports hooks that customize Node.js module
|
|
221
234
|
* resolution and loading behavior. See
|
|
222
|
-
* [Customization hooks](https://nodejs.org/docs/latest-
|
|
235
|
+
* [Customization hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks).
|
|
223
236
|
*
|
|
224
237
|
* This feature requires `--allow-worker` if used with the
|
|
225
|
-
* [Permission Model](https://nodejs.org/docs/latest-
|
|
238
|
+
* [Permission Model](https://nodejs.org/docs/latest-v25.x/api/permissions.html#permission-model).
|
|
226
239
|
* @since v20.6.0, v18.19.0
|
|
227
240
|
* @param specifier Customization hooks to be registered; this should be
|
|
228
241
|
* the same string that would be passed to `import()`, except that if it is
|
|
@@ -238,12 +251,12 @@ declare module "node:module" {
|
|
|
238
251
|
function register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
|
|
239
252
|
interface RegisterHooksOptions {
|
|
240
253
|
/**
|
|
241
|
-
* See [load hook](https://nodejs.org/docs/latest-
|
|
254
|
+
* See [load hook](https://nodejs.org/docs/latest-v25.x/api/module.html#loadurl-context-nextload).
|
|
242
255
|
* @default undefined
|
|
243
256
|
*/
|
|
244
257
|
load?: LoadHookSync | undefined;
|
|
245
258
|
/**
|
|
246
|
-
* See [resolve hook](https://nodejs.org/docs/latest-
|
|
259
|
+
* See [resolve hook](https://nodejs.org/docs/latest-v25.x/api/module.html#resolvespecifier-context-nextresolve).
|
|
247
260
|
* @default undefined
|
|
248
261
|
*/
|
|
249
262
|
resolve?: ResolveHookSync | undefined;
|
|
@@ -255,7 +268,7 @@ declare module "node:module" {
|
|
|
255
268
|
deregister(): void;
|
|
256
269
|
}
|
|
257
270
|
/**
|
|
258
|
-
* Register [hooks](https://nodejs.org/docs/latest-
|
|
271
|
+
* Register [hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks)
|
|
259
272
|
* that customize Node.js module resolution and loading behavior.
|
|
260
273
|
* @since v22.15.0
|
|
261
274
|
* @experimental
|
|
@@ -286,9 +299,9 @@ declare module "node:module" {
|
|
|
286
299
|
* with `vm.runInContext()` or `vm.compileFunction()`.
|
|
287
300
|
* By default, it will throw an error if the code contains TypeScript features
|
|
288
301
|
* that require transformation such as `Enums`,
|
|
289
|
-
* see [type-stripping](https://nodejs.org/docs/latest-
|
|
302
|
+
* see [type-stripping](https://nodejs.org/docs/latest-v25.x/api/typescript.md#type-stripping) for more information.
|
|
290
303
|
* When mode is `'transform'`, it also transforms TypeScript features to JavaScript,
|
|
291
|
-
* see [transform TypeScript features](https://nodejs.org/docs/latest-
|
|
304
|
+
* see [transform TypeScript features](https://nodejs.org/docs/latest-v25.x/api/typescript.md#typescript-features) for more information.
|
|
292
305
|
* When mode is `'strip'`, source maps are not generated, because locations are preserved.
|
|
293
306
|
* If `sourceMap` is provided, when mode is `'strip'`, an error will be thrown.
|
|
294
307
|
*
|
|
@@ -375,6 +388,7 @@ declare module "node:module" {
|
|
|
375
388
|
interface ImportAttributes extends NodeJS.Dict<string> {
|
|
376
389
|
type?: string | undefined;
|
|
377
390
|
}
|
|
391
|
+
type ImportPhase = "source" | "evaluation";
|
|
378
392
|
type ModuleFormat =
|
|
379
393
|
| "addon"
|
|
380
394
|
| "builtin"
|
|
@@ -638,70 +652,6 @@ declare module "node:module" {
|
|
|
638
652
|
function wrap(script: string): string;
|
|
639
653
|
}
|
|
640
654
|
global {
|
|
641
|
-
interface ImportMeta {
|
|
642
|
-
/**
|
|
643
|
-
* The directory name of the current module.
|
|
644
|
-
*
|
|
645
|
-
* This is the same as the `path.dirname()` of the `import.meta.filename`.
|
|
646
|
-
*
|
|
647
|
-
* > **Caveat**: only present on `file:` modules.
|
|
648
|
-
* @since v21.2.0, v20.11.0
|
|
649
|
-
*/
|
|
650
|
-
dirname: string;
|
|
651
|
-
/**
|
|
652
|
-
* The full absolute path and filename of the current module, with
|
|
653
|
-
* symlinks resolved.
|
|
654
|
-
*
|
|
655
|
-
* This is the same as the `url.fileURLToPath()` of the `import.meta.url`.
|
|
656
|
-
*
|
|
657
|
-
* > **Caveat** only local modules support this property. Modules not using the
|
|
658
|
-
* > `file:` protocol will not provide it.
|
|
659
|
-
* @since v21.2.0, v20.11.0
|
|
660
|
-
*/
|
|
661
|
-
filename: string;
|
|
662
|
-
/**
|
|
663
|
-
* The absolute `file:` URL of the module.
|
|
664
|
-
*
|
|
665
|
-
* This is defined exactly the same as it is in browsers providing the URL of the
|
|
666
|
-
* current module file.
|
|
667
|
-
*
|
|
668
|
-
* This enables useful patterns such as relative file loading:
|
|
669
|
-
*
|
|
670
|
-
* ```js
|
|
671
|
-
* import { readFileSync } from 'node:fs';
|
|
672
|
-
* const buffer = readFileSync(new URL('./data.proto', import.meta.url));
|
|
673
|
-
* ```
|
|
674
|
-
*/
|
|
675
|
-
url: string;
|
|
676
|
-
/**
|
|
677
|
-
* `import.meta.resolve` is a module-relative resolution function scoped to
|
|
678
|
-
* each module, returning the URL string.
|
|
679
|
-
*
|
|
680
|
-
* ```js
|
|
681
|
-
* const dependencyAsset = import.meta.resolve('component-lib/asset.css');
|
|
682
|
-
* // file:///app/node_modules/component-lib/asset.css
|
|
683
|
-
* import.meta.resolve('./dep.js');
|
|
684
|
-
* // file:///app/dep.js
|
|
685
|
-
* ```
|
|
686
|
-
*
|
|
687
|
-
* All features of the Node.js module resolution are supported. Dependency
|
|
688
|
-
* resolutions are subject to the permitted exports resolutions within the package.
|
|
689
|
-
*
|
|
690
|
-
* **Caveats**:
|
|
691
|
-
*
|
|
692
|
-
* * This can result in synchronous file-system operations, which
|
|
693
|
-
* can impact performance similarly to `require.resolve`.
|
|
694
|
-
* * This feature is not available within custom loaders (it would
|
|
695
|
-
* create a deadlock).
|
|
696
|
-
* @since v13.9.0, v12.16.0
|
|
697
|
-
* @param specifier The module specifier to resolve relative to the
|
|
698
|
-
* current module.
|
|
699
|
-
* @param parent An optional absolute parent module URL to resolve from.
|
|
700
|
-
* **Default:** `import.meta.url`
|
|
701
|
-
* @returns The absolute URL string that the specifier would resolve to.
|
|
702
|
-
*/
|
|
703
|
-
resolve(specifier: string, parent?: string | URL): string;
|
|
704
|
-
}
|
|
705
655
|
namespace NodeJS {
|
|
706
656
|
interface Module {
|
|
707
657
|
/**
|
|
@@ -775,7 +725,7 @@ declare module "node:module" {
|
|
|
775
725
|
* Modules are cached in this object when they are required. By deleting a key
|
|
776
726
|
* value from this object, the next `require` will reload the module.
|
|
777
727
|
* This does not apply to
|
|
778
|
-
* [native addons](https://nodejs.org/docs/latest-
|
|
728
|
+
* [native addons](https://nodejs.org/docs/latest-v25.x/api/addons.html),
|
|
779
729
|
* for which reloading will result in an error.
|
|
780
730
|
* @since v0.3.0
|
|
781
731
|
*/
|
|
@@ -809,7 +759,7 @@ declare module "node:module" {
|
|
|
809
759
|
* Paths to resolve module location from. If present, these
|
|
810
760
|
* paths are used instead of the default resolution paths, with the exception
|
|
811
761
|
* of
|
|
812
|
-
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-
|
|
762
|
+
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v25.x/api/modules.html#loading-from-the-global-folders)
|
|
813
763
|
* like `$HOME/.node_modules`, which are
|
|
814
764
|
* always included. Each of these paths is used as a starting point for
|
|
815
765
|
* the module resolution algorithm, meaning that the `node_modules` hierarchy
|
package/net.d.ts
CHANGED
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
* ```js
|
|
26
26
|
* import net from 'node:net';
|
|
27
27
|
* ```
|
|
28
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
28
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/net.js)
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
declare module "node:net" {
|
|
32
|
-
import
|
|
33
|
-
import { Abortable, EventEmitter } from 'node:events';
|
|
32
|
+
import { NonSharedBuffer } from 'node:buffer';
|
|
34
33
|
import * as dns from '_not-use-node-type_dns';
|
|
34
|
+
import { Abortable, EventEmitter, InternalEventEmitter } from 'node:events';
|
|
35
|
+
import * as stream from 'node:stream';
|
|
35
36
|
type LookupFunction = (
|
|
36
37
|
hostname: string,
|
|
37
38
|
options: dns.LookupOptions,
|
|
@@ -48,7 +49,7 @@ declare module "node:net" {
|
|
|
48
49
|
onread?: OnReadOpts | undefined;
|
|
49
50
|
readable?: boolean | undefined;
|
|
50
51
|
writable?: boolean | undefined;
|
|
51
|
-
signal?: AbortSignal;
|
|
52
|
+
signal?: AbortSignal | undefined;
|
|
52
53
|
}
|
|
53
54
|
interface OnReadOpts {
|
|
54
55
|
buffer: Uint8Array | (() => Uint8Array);
|
|
@@ -85,6 +86,17 @@ declare module "node:net" {
|
|
|
85
86
|
}
|
|
86
87
|
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
|
87
88
|
type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed";
|
|
89
|
+
interface SocketEventMap extends Omit<stream.DuplexEventMap, "close"> {
|
|
90
|
+
"close": [hadError: boolean];
|
|
91
|
+
"connect": [];
|
|
92
|
+
"connectionAttempt": [ip: string, port: number, family: number];
|
|
93
|
+
"connectionAttemptFailed": [ip: string, port: number, family: number, error: Error];
|
|
94
|
+
"connectionAttemptTimeout": [ip: string, port: number, family: number];
|
|
95
|
+
"data": [data: string | NonSharedBuffer];
|
|
96
|
+
"lookup": [err: Error | null, address: string, family: number | null, host: string];
|
|
97
|
+
"ready": [];
|
|
98
|
+
"timeout": [];
|
|
99
|
+
}
|
|
88
100
|
/**
|
|
89
101
|
* This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
|
|
90
102
|
* (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
|
|
@@ -337,25 +349,25 @@ declare module "node:net" {
|
|
|
337
349
|
* the socket is destroyed (for example, if the client disconnected).
|
|
338
350
|
* @since v0.5.10
|
|
339
351
|
*/
|
|
340
|
-
readonly remoteAddress
|
|
352
|
+
readonly remoteAddress: string | undefined;
|
|
341
353
|
/**
|
|
342
354
|
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
|
|
343
355
|
* the socket is destroyed (for example, if the client disconnected).
|
|
344
356
|
* @since v0.11.14
|
|
345
357
|
*/
|
|
346
|
-
readonly remoteFamily
|
|
358
|
+
readonly remoteFamily: string | undefined;
|
|
347
359
|
/**
|
|
348
360
|
* The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
|
|
349
361
|
* the socket is destroyed (for example, if the client disconnected).
|
|
350
362
|
* @since v0.5.10
|
|
351
363
|
*/
|
|
352
|
-
readonly remotePort
|
|
364
|
+
readonly remotePort: number | undefined;
|
|
353
365
|
/**
|
|
354
366
|
* The socket timeout in milliseconds as set by `socket.setTimeout()`.
|
|
355
367
|
* It is `undefined` if a timeout has not been set.
|
|
356
368
|
* @since v10.7.0
|
|
357
369
|
*/
|
|
358
|
-
readonly timeout?: number
|
|
370
|
+
readonly timeout?: number;
|
|
359
371
|
/**
|
|
360
372
|
* Half-closes the socket. i.e., it sends a FIN packet. It is possible the
|
|
361
373
|
* server will still send some data.
|
|
@@ -369,141 +381,45 @@ declare module "node:net" {
|
|
|
369
381
|
end(callback?: () => void): this;
|
|
370
382
|
end(buffer: Uint8Array | string, callback?: () => void): this;
|
|
371
383
|
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
listener: (ip: string, port: number, family: number, error: Error) => void,
|
|
394
|
-
): this;
|
|
395
|
-
addListener(
|
|
396
|
-
event: "connectionAttemptTimeout",
|
|
397
|
-
listener: (ip: string, port: number, family: number) => void,
|
|
398
|
-
): this;
|
|
399
|
-
addListener(event: "data", listener: (data: Buffer) => void): this;
|
|
400
|
-
addListener(event: "drain", listener: () => void): this;
|
|
401
|
-
addListener(event: "end", listener: () => void): this;
|
|
402
|
-
addListener(event: "error", listener: (err: Error) => void): this;
|
|
403
|
-
addListener(
|
|
404
|
-
event: "lookup",
|
|
405
|
-
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
|
406
|
-
): this;
|
|
407
|
-
addListener(event: "ready", listener: () => void): this;
|
|
408
|
-
addListener(event: "timeout", listener: () => void): this;
|
|
409
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
410
|
-
emit(event: "close", hadError: boolean): boolean;
|
|
411
|
-
emit(event: "connect"): boolean;
|
|
412
|
-
emit(event: "connectionAttempt", ip: string, port: number, family: number): boolean;
|
|
413
|
-
emit(event: "connectionAttemptFailed", ip: string, port: number, family: number, error: Error): boolean;
|
|
414
|
-
emit(event: "connectionAttemptTimeout", ip: string, port: number, family: number): boolean;
|
|
415
|
-
emit(event: "data", data: Buffer): boolean;
|
|
416
|
-
emit(event: "drain"): boolean;
|
|
417
|
-
emit(event: "end"): boolean;
|
|
418
|
-
emit(event: "error", err: Error): boolean;
|
|
419
|
-
emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
|
|
420
|
-
emit(event: "ready"): boolean;
|
|
421
|
-
emit(event: "timeout"): boolean;
|
|
422
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
423
|
-
on(event: "close", listener: (hadError: boolean) => void): this;
|
|
424
|
-
on(event: "connect", listener: () => void): this;
|
|
425
|
-
on(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
|
426
|
-
on(
|
|
427
|
-
event: "connectionAttemptFailed",
|
|
428
|
-
listener: (ip: string, port: number, family: number, error: Error) => void,
|
|
429
|
-
): this;
|
|
430
|
-
on(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
|
|
431
|
-
on(event: "data", listener: (data: Buffer) => void): this;
|
|
432
|
-
on(event: "drain", listener: () => void): this;
|
|
433
|
-
on(event: "end", listener: () => void): this;
|
|
434
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
435
|
-
on(
|
|
436
|
-
event: "lookup",
|
|
437
|
-
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
|
438
|
-
): this;
|
|
439
|
-
on(event: "ready", listener: () => void): this;
|
|
440
|
-
on(event: "timeout", listener: () => void): this;
|
|
441
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
442
|
-
once(event: "close", listener: (hadError: boolean) => void): this;
|
|
443
|
-
once(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
|
444
|
-
once(
|
|
445
|
-
event: "connectionAttemptFailed",
|
|
446
|
-
listener: (ip: string, port: number, family: number, error: Error) => void,
|
|
447
|
-
): this;
|
|
448
|
-
once(event: "connectionAttemptTimeout", listener: (ip: string, port: number, family: number) => void): this;
|
|
449
|
-
once(event: "connect", listener: () => void): this;
|
|
450
|
-
once(event: "data", listener: (data: Buffer) => void): this;
|
|
451
|
-
once(event: "drain", listener: () => void): this;
|
|
452
|
-
once(event: "end", listener: () => void): this;
|
|
453
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
454
|
-
once(
|
|
455
|
-
event: "lookup",
|
|
456
|
-
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
|
457
|
-
): this;
|
|
458
|
-
once(event: "ready", listener: () => void): this;
|
|
459
|
-
once(event: "timeout", listener: () => void): this;
|
|
460
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
461
|
-
prependListener(event: "close", listener: (hadError: boolean) => void): this;
|
|
462
|
-
prependListener(event: "connect", listener: () => void): this;
|
|
463
|
-
prependListener(event: "connectionAttempt", listener: (ip: string, port: number, family: number) => void): this;
|
|
464
|
-
prependListener(
|
|
465
|
-
event: "connectionAttemptFailed",
|
|
466
|
-
listener: (ip: string, port: number, family: number, error: Error) => void,
|
|
467
|
-
): this;
|
|
468
|
-
prependListener(
|
|
469
|
-
event: "connectionAttemptTimeout",
|
|
470
|
-
listener: (ip: string, port: number, family: number) => void,
|
|
384
|
+
// #region InternalEventEmitter
|
|
385
|
+
addListener<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
|
|
386
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
387
|
+
emit<E extends keyof SocketEventMap>(eventName: E, ...args: SocketEventMap[E]): boolean;
|
|
388
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
389
|
+
listenerCount<E extends keyof SocketEventMap>(
|
|
390
|
+
eventName: E,
|
|
391
|
+
listener?: (...args: SocketEventMap[E]) => void,
|
|
392
|
+
): number;
|
|
393
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
394
|
+
listeners<E extends keyof SocketEventMap>(eventName: E): ((...args: SocketEventMap[E]) => void)[];
|
|
395
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
396
|
+
off<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
|
|
397
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
398
|
+
on<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
|
|
399
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
400
|
+
once<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
|
|
401
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
402
|
+
prependListener<E extends keyof SocketEventMap>(
|
|
403
|
+
eventName: E,
|
|
404
|
+
listener: (...args: SocketEventMap[E]) => void,
|
|
471
405
|
): this;
|
|
472
|
-
prependListener(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
prependListener(
|
|
477
|
-
event: "lookup",
|
|
478
|
-
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
|
406
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
407
|
+
prependOnceListener<E extends keyof SocketEventMap>(
|
|
408
|
+
eventName: E,
|
|
409
|
+
listener: (...args: SocketEventMap[E]) => void,
|
|
479
410
|
): this;
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
411
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
412
|
+
rawListeners<E extends keyof SocketEventMap>(eventName: E): ((...args: SocketEventMap[E]) => void)[];
|
|
413
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
414
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
415
|
+
removeAllListeners<E extends keyof SocketEventMap>(eventName?: E): this;
|
|
416
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
417
|
+
removeListener<E extends keyof SocketEventMap>(
|
|
418
|
+
eventName: E,
|
|
419
|
+
listener: (...args: SocketEventMap[E]) => void,
|
|
488
420
|
): this;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
listener: (ip: string, port: number, family: number, error: Error) => void,
|
|
492
|
-
): this;
|
|
493
|
-
prependOnceListener(
|
|
494
|
-
event: "connectionAttemptTimeout",
|
|
495
|
-
listener: (ip: string, port: number, family: number) => void,
|
|
496
|
-
): this;
|
|
497
|
-
prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
|
|
498
|
-
prependOnceListener(event: "drain", listener: () => void): this;
|
|
499
|
-
prependOnceListener(event: "end", listener: () => void): this;
|
|
500
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
501
|
-
prependOnceListener(
|
|
502
|
-
event: "lookup",
|
|
503
|
-
listener: (err: Error, address: string, family: string | number, host: string) => void,
|
|
504
|
-
): this;
|
|
505
|
-
prependOnceListener(event: "ready", listener: () => void): this;
|
|
506
|
-
prependOnceListener(event: "timeout", listener: () => void): this;
|
|
421
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
422
|
+
// #endregion
|
|
507
423
|
}
|
|
508
424
|
interface ListenOptions extends Abortable {
|
|
509
425
|
backlog?: number | undefined;
|
|
@@ -551,7 +467,7 @@ declare module "node:net" {
|
|
|
551
467
|
keepAliveInitialDelay?: number | undefined;
|
|
552
468
|
/**
|
|
553
469
|
* Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
|
|
554
|
-
* @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-
|
|
470
|
+
* @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
|
|
555
471
|
* @since v18.17.0, v20.1.0
|
|
556
472
|
*/
|
|
557
473
|
highWaterMark?: number | undefined;
|
|
@@ -573,11 +489,18 @@ declare module "node:net" {
|
|
|
573
489
|
remotePort?: number;
|
|
574
490
|
remoteFamily?: string;
|
|
575
491
|
}
|
|
492
|
+
interface ServerEventMap {
|
|
493
|
+
"close": [];
|
|
494
|
+
"connection": [socket: Socket];
|
|
495
|
+
"error": [err: Error];
|
|
496
|
+
"listening": [];
|
|
497
|
+
"drop": [data?: DropArgument];
|
|
498
|
+
}
|
|
576
499
|
/**
|
|
577
500
|
* This class is used to create a TCP or `IPC` server.
|
|
578
501
|
* @since v0.1.90
|
|
579
502
|
*/
|
|
580
|
-
class Server
|
|
503
|
+
class Server implements EventEmitter {
|
|
581
504
|
constructor(connectionListener?: (socket: Socket) => void);
|
|
582
505
|
constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
|
|
583
506
|
/**
|
|
@@ -703,56 +626,13 @@ declare module "node:net" {
|
|
|
703
626
|
* @since v5.7.0
|
|
704
627
|
*/
|
|
705
628
|
readonly listening: boolean;
|
|
706
|
-
/**
|
|
707
|
-
* events.EventEmitter
|
|
708
|
-
* 1. close
|
|
709
|
-
* 2. connection
|
|
710
|
-
* 3. error
|
|
711
|
-
* 4. listening
|
|
712
|
-
* 5. drop
|
|
713
|
-
*/
|
|
714
|
-
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
715
|
-
addListener(event: "close", listener: () => void): this;
|
|
716
|
-
addListener(event: "connection", listener: (socket: Socket) => void): this;
|
|
717
|
-
addListener(event: "error", listener: (err: Error) => void): this;
|
|
718
|
-
addListener(event: "listening", listener: () => void): this;
|
|
719
|
-
addListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
|
720
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
721
|
-
emit(event: "close"): boolean;
|
|
722
|
-
emit(event: "connection", socket: Socket): boolean;
|
|
723
|
-
emit(event: "error", err: Error): boolean;
|
|
724
|
-
emit(event: "listening"): boolean;
|
|
725
|
-
emit(event: "drop", data?: DropArgument): boolean;
|
|
726
|
-
on(event: string, listener: (...args: any[]) => void): this;
|
|
727
|
-
on(event: "close", listener: () => void): this;
|
|
728
|
-
on(event: "connection", listener: (socket: Socket) => void): this;
|
|
729
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
730
|
-
on(event: "listening", listener: () => void): this;
|
|
731
|
-
on(event: "drop", listener: (data?: DropArgument) => void): this;
|
|
732
|
-
once(event: string, listener: (...args: any[]) => void): this;
|
|
733
|
-
once(event: "close", listener: () => void): this;
|
|
734
|
-
once(event: "connection", listener: (socket: Socket) => void): this;
|
|
735
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
736
|
-
once(event: "listening", listener: () => void): this;
|
|
737
|
-
once(event: "drop", listener: (data?: DropArgument) => void): this;
|
|
738
|
-
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
739
|
-
prependListener(event: "close", listener: () => void): this;
|
|
740
|
-
prependListener(event: "connection", listener: (socket: Socket) => void): this;
|
|
741
|
-
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
742
|
-
prependListener(event: "listening", listener: () => void): this;
|
|
743
|
-
prependListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
|
744
|
-
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
745
|
-
prependOnceListener(event: "close", listener: () => void): this;
|
|
746
|
-
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
|
|
747
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
748
|
-
prependOnceListener(event: "listening", listener: () => void): this;
|
|
749
|
-
prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this;
|
|
750
629
|
/**
|
|
751
630
|
* Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
|
|
752
631
|
* @since v20.5.0
|
|
753
632
|
*/
|
|
754
633
|
[Symbol.asyncDispose](): Promise<void>;
|
|
755
634
|
}
|
|
635
|
+
interface Server extends InternalEventEmitter<ServerEventMap> {}
|
|
756
636
|
type IPVersion = "ipv4" | "ipv6";
|
|
757
637
|
/**
|
|
758
638
|
* The `BlockList` object can be used with some network APIs to specify rules for
|
|
@@ -821,6 +701,27 @@ declare module "node:net" {
|
|
|
821
701
|
* @param value Any JS value
|
|
822
702
|
*/
|
|
823
703
|
static isBlockList(value: unknown): value is BlockList;
|
|
704
|
+
/**
|
|
705
|
+
* ```js
|
|
706
|
+
* const blockList = new net.BlockList();
|
|
707
|
+
* const data = [
|
|
708
|
+
* 'Subnet: IPv4 192.168.1.0/24',
|
|
709
|
+
* 'Address: IPv4 10.0.0.5',
|
|
710
|
+
* 'Range: IPv4 192.168.2.1-192.168.2.10',
|
|
711
|
+
* 'Range: IPv4 10.0.0.1-10.0.0.10',
|
|
712
|
+
* ];
|
|
713
|
+
* blockList.fromJSON(data);
|
|
714
|
+
* blockList.fromJSON(JSON.stringify(data));
|
|
715
|
+
* ```
|
|
716
|
+
* @since v24.5.0
|
|
717
|
+
* @experimental
|
|
718
|
+
*/
|
|
719
|
+
fromJSON(data: string | readonly string[]): void;
|
|
720
|
+
/**
|
|
721
|
+
* @since v24.5.0
|
|
722
|
+
* @experimental
|
|
723
|
+
*/
|
|
724
|
+
toJSON(): readonly string[];
|
|
824
725
|
}
|
|
825
726
|
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
|
826
727
|
timeout?: number | undefined;
|