@types/node 18.7.23 → 18.11.8
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.
- node/README.md +1 -1
- node/assert.d.ts +50 -0
- node/buffer.d.ts +22 -2
- node/crypto.d.ts +7 -4
- node/dom-events.d.ts +126 -0
- node/events.d.ts +43 -6
- node/fs/promises.d.ts +18 -0
- node/globals.d.ts +16 -12
- node/http.d.ts +63 -2
- node/http2.d.ts +28 -0
- node/index.d.ts +2 -1
- node/net.d.ts +33 -2
- node/package.json +2 -2
- node/path.d.ts +2 -2
- node/perf_hooks.d.ts +15 -0
- node/querystring.d.ts +3 -3
- node/stream/consumers.d.ts +2 -14
- node/stream.d.ts +5 -4
- node/ts4.8/assert.d.ts +50 -0
- node/ts4.8/buffer.d.ts +23 -2
- node/ts4.8/crypto.d.ts +7 -4
- node/ts4.8/dom-events.d.ts +126 -0
- node/ts4.8/events.d.ts +43 -6
- node/ts4.8/fs/promises.d.ts +18 -0
- node/ts4.8/globals.d.ts +1 -1
- node/ts4.8/http.d.ts +63 -2
- node/ts4.8/http2.d.ts +28 -0
- node/ts4.8/index.d.ts +1 -0
- node/ts4.8/net.d.ts +33 -2
- node/ts4.8/path.d.ts +2 -2
- node/ts4.8/perf_hooks.d.ts +15 -0
- node/ts4.8/querystring.d.ts +3 -3
- node/ts4.8/stream/consumers.d.ts +2 -14
- node/ts4.8/stream.d.ts +2 -1
- node/ts4.8/test.d.ts +129 -5
- node/ts4.8/url.d.ts +6 -6
- node/ts4.8/util.d.ts +58 -0
- node/ts4.8/worker_threads.d.ts +43 -0
- node/url.d.ts +6 -6
- node/util.d.ts +58 -0
- node/worker_threads.d.ts +43 -0
node/net.d.ts
CHANGED
|
@@ -131,6 +131,17 @@ declare module 'net' {
|
|
|
131
131
|
* @return The socket itself.
|
|
132
132
|
*/
|
|
133
133
|
pause(): this;
|
|
134
|
+
/**
|
|
135
|
+
* Close the TCP connection by sending an RST packet and destroy the stream.
|
|
136
|
+
* If this TCP socket is in connecting status, it will send an RST packet
|
|
137
|
+
* and destroy this TCP socket once it is connected. Otherwise, it will call
|
|
138
|
+
* `socket.destroy` with an `ERR_SOCKET_CLOSED` Error. If this is not a TCP socket
|
|
139
|
+
* (for example, a pipe), calling this method will immediately throw
|
|
140
|
+
* an `ERR_INVALID_HANDLE_TYPE` Error.
|
|
141
|
+
* @since v18.3.0
|
|
142
|
+
* @return The socket itself.
|
|
143
|
+
*/
|
|
144
|
+
resetAndDestroy(): this;
|
|
134
145
|
/**
|
|
135
146
|
* Resumes reading after a call to `socket.pause()`.
|
|
136
147
|
* @return The socket itself.
|
|
@@ -266,6 +277,11 @@ declare module 'net' {
|
|
|
266
277
|
* @since v0.9.6
|
|
267
278
|
*/
|
|
268
279
|
readonly localPort?: number;
|
|
280
|
+
/**
|
|
281
|
+
* The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
|
|
282
|
+
* @since v18.8.0
|
|
283
|
+
*/
|
|
284
|
+
readonly localFamily?: string;
|
|
269
285
|
/**
|
|
270
286
|
* This property represents the state of the connection as a string.
|
|
271
287
|
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
|
@@ -315,7 +331,8 @@ declare module 'net' {
|
|
|
315
331
|
* 5. end
|
|
316
332
|
* 6. error
|
|
317
333
|
* 7. lookup
|
|
318
|
-
* 8.
|
|
334
|
+
* 8. ready
|
|
335
|
+
* 9. timeout
|
|
319
336
|
*/
|
|
320
337
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
321
338
|
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
|
@@ -422,6 +439,14 @@ declare module 'net' {
|
|
|
422
439
|
*/
|
|
423
440
|
keepAliveInitialDelay?: number | undefined;
|
|
424
441
|
}
|
|
442
|
+
interface DropArgument {
|
|
443
|
+
localAddress?: string;
|
|
444
|
+
localPort?: number;
|
|
445
|
+
localFamily?: string;
|
|
446
|
+
remoteAddress?: string;
|
|
447
|
+
remotePort?: number;
|
|
448
|
+
remoteFamily?: string;
|
|
449
|
+
}
|
|
425
450
|
/**
|
|
426
451
|
* This class is used to create a TCP or `IPC` server.
|
|
427
452
|
* @since v0.1.90
|
|
@@ -558,37 +583,44 @@ declare module 'net' {
|
|
|
558
583
|
* 2. connection
|
|
559
584
|
* 3. error
|
|
560
585
|
* 4. listening
|
|
586
|
+
* 5. drop
|
|
561
587
|
*/
|
|
562
588
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
563
589
|
addListener(event: 'close', listener: () => void): this;
|
|
564
590
|
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
|
565
591
|
addListener(event: 'error', listener: (err: Error) => void): this;
|
|
566
592
|
addListener(event: 'listening', listener: () => void): this;
|
|
593
|
+
addListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
|
567
594
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
568
595
|
emit(event: 'close'): boolean;
|
|
569
596
|
emit(event: 'connection', socket: Socket): boolean;
|
|
570
597
|
emit(event: 'error', err: Error): boolean;
|
|
571
598
|
emit(event: 'listening'): boolean;
|
|
599
|
+
emit(event: 'drop', data?: DropArgument): boolean;
|
|
572
600
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
573
601
|
on(event: 'close', listener: () => void): this;
|
|
574
602
|
on(event: 'connection', listener: (socket: Socket) => void): this;
|
|
575
603
|
on(event: 'error', listener: (err: Error) => void): this;
|
|
576
604
|
on(event: 'listening', listener: () => void): this;
|
|
605
|
+
on(event: 'drop', listener: (data?: DropArgument) => void): this;
|
|
577
606
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
578
607
|
once(event: 'close', listener: () => void): this;
|
|
579
608
|
once(event: 'connection', listener: (socket: Socket) => void): this;
|
|
580
609
|
once(event: 'error', listener: (err: Error) => void): this;
|
|
581
610
|
once(event: 'listening', listener: () => void): this;
|
|
611
|
+
once(event: 'drop', listener: (data?: DropArgument) => void): this;
|
|
582
612
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
583
613
|
prependListener(event: 'close', listener: () => void): this;
|
|
584
614
|
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
|
585
615
|
prependListener(event: 'error', listener: (err: Error) => void): this;
|
|
586
616
|
prependListener(event: 'listening', listener: () => void): this;
|
|
617
|
+
prependListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
|
587
618
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
588
619
|
prependOnceListener(event: 'close', listener: () => void): this;
|
|
589
620
|
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
|
590
621
|
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
|
591
622
|
prependOnceListener(event: 'listening', listener: () => void): this;
|
|
623
|
+
prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
|
|
592
624
|
}
|
|
593
625
|
type IPVersion = 'ipv4' | 'ipv6';
|
|
594
626
|
/**
|
|
@@ -814,7 +846,6 @@ declare module 'net' {
|
|
|
814
846
|
class SocketAddress {
|
|
815
847
|
constructor(options: SocketAddressInitOptions);
|
|
816
848
|
/**
|
|
817
|
-
* Either \`'ipv4'\` or \`'ipv6'\`.
|
|
818
849
|
* @since v15.14.0, v14.18.0
|
|
819
850
|
*/
|
|
820
851
|
readonly address: string;
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.11.8",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -227,6 +227,6 @@
|
|
|
227
227
|
},
|
|
228
228
|
"scripts": {},
|
|
229
229
|
"dependencies": {},
|
|
230
|
-
"typesPublisherContentHash": "
|
|
230
|
+
"typesPublisherContentHash": "a23a6d5ceb48ac0215ccd7cba47e75f2a3ae678b228d576c89294138777a2847",
|
|
231
231
|
"typeScriptVersion": "4.1"
|
|
232
232
|
}
|
node/path.d.ts
CHANGED
|
@@ -122,10 +122,10 @@ declare module 'path' {
|
|
|
122
122
|
* Often used to extract the file name from a fully qualified path.
|
|
123
123
|
*
|
|
124
124
|
* @param path the path to evaluate.
|
|
125
|
-
* @param
|
|
125
|
+
* @param suffix optionally, an extension to remove from the result.
|
|
126
126
|
* @throws {TypeError} if `path` is not a string or if `ext` is given and is not a string.
|
|
127
127
|
*/
|
|
128
|
-
basename(path: string,
|
|
128
|
+
basename(path: string, suffix?: string): string;
|
|
129
129
|
/**
|
|
130
130
|
* Return the extension of the path, from the last '.' to end of string in the last portion of the path.
|
|
131
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.
|
node/perf_hooks.d.ts
CHANGED
|
@@ -604,6 +604,21 @@ declare module 'perf_hooks' {
|
|
|
604
604
|
* @since v15.9.0, v14.18.0
|
|
605
605
|
*/
|
|
606
606
|
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
|
|
607
|
+
|
|
608
|
+
import { performance as _performance } from 'perf_hooks';
|
|
609
|
+
global {
|
|
610
|
+
/**
|
|
611
|
+
* `performance` is a global reference for `require('perf_hooks').performance`
|
|
612
|
+
* https://nodejs.org/api/globals.html#performance
|
|
613
|
+
* @since v16.0.0
|
|
614
|
+
*/
|
|
615
|
+
var performance: typeof globalThis extends {
|
|
616
|
+
onmessage: any;
|
|
617
|
+
performance: infer T;
|
|
618
|
+
}
|
|
619
|
+
? T
|
|
620
|
+
: typeof _performance;
|
|
621
|
+
}
|
|
607
622
|
}
|
|
608
623
|
declare module 'node:perf_hooks' {
|
|
609
624
|
export * from 'perf_hooks';
|
node/querystring.d.ts
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* const querystring = require('querystring');
|
|
7
7
|
* ```
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* `querystring` is more performant than `URLSearchParams` but is not a
|
|
10
|
+
* standardized API. Use `URLSearchParams` when performance is not critical
|
|
11
|
+
* or when compatibility with browser code is desirable.
|
|
12
12
|
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/querystring.js)
|
|
13
13
|
*/
|
|
14
14
|
declare module 'querystring' {
|
node/stream/consumers.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
// Duplicates of interface in lib.dom.ts.
|
|
2
|
-
// Duplicated here rather than referencing lib.dom.ts because doing so causes lib.dom.ts to be loaded for "test-all"
|
|
3
|
-
// Which in turn causes tests to pass that shouldn't pass.
|
|
4
|
-
//
|
|
5
|
-
// This interface is not, and should not be, exported.
|
|
6
|
-
interface Blob {
|
|
7
|
-
readonly size: number;
|
|
8
|
-
readonly type: string;
|
|
9
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
10
|
-
slice(start?: number, end?: number, contentType?: string): Blob;
|
|
11
|
-
stream(): NodeJS.ReadableStream;
|
|
12
|
-
text(): Promise<string>;
|
|
13
|
-
}
|
|
14
1
|
declare module 'stream/consumers' {
|
|
2
|
+
import { Blob as NodeBlob } from "node:buffer";
|
|
15
3
|
import { Readable } from 'node:stream';
|
|
16
4
|
function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<Buffer>;
|
|
17
5
|
function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<string>;
|
|
18
6
|
function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<ArrayBuffer>;
|
|
19
|
-
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<
|
|
7
|
+
function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<NodeBlob>;
|
|
20
8
|
function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator<any>): Promise<unknown>;
|
|
21
9
|
}
|
|
22
10
|
declare module 'node:stream/consumers' {
|
node/stream.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
declare module 'stream' {
|
|
20
20
|
import { EventEmitter, Abortable } from 'node:events';
|
|
21
|
+
import { Blob as NodeBlob } from "node:buffer";
|
|
21
22
|
import * as streamPromises from 'node:stream/promises';
|
|
22
23
|
import * as streamConsumers from 'node:stream/consumers';
|
|
23
24
|
import * as streamWeb from 'node:stream/web';
|
|
@@ -123,12 +124,12 @@ declare module 'stream' {
|
|
|
123
124
|
readonly readableObjectMode: boolean;
|
|
124
125
|
/**
|
|
125
126
|
* Is `true` after `readable.destroy()` has been called.
|
|
126
|
-
* @since
|
|
127
|
+
* @since v8.0.0
|
|
127
128
|
*/
|
|
128
129
|
destroyed: boolean;
|
|
129
130
|
/**
|
|
130
131
|
* Is true after 'close' has been emitted.
|
|
131
|
-
* @since
|
|
132
|
+
* @since v18.0.0
|
|
132
133
|
*/
|
|
133
134
|
readonly closed: boolean;
|
|
134
135
|
/**
|
|
@@ -578,7 +579,7 @@ declare module 'stream' {
|
|
|
578
579
|
destroyed: boolean;
|
|
579
580
|
/**
|
|
580
581
|
* Is true after 'close' has been emitted.
|
|
581
|
-
* @since
|
|
582
|
+
* @since v18.0.0
|
|
582
583
|
*/
|
|
583
584
|
readonly closed: boolean;
|
|
584
585
|
/**
|
|
@@ -892,7 +893,7 @@ declare module 'stream' {
|
|
|
892
893
|
*
|
|
893
894
|
* @since v16.8.0
|
|
894
895
|
*/
|
|
895
|
-
static from(src: Stream |
|
|
896
|
+
static from(src: Stream | NodeBlob | ArrayBuffer | string | Iterable<any> | AsyncIterable<any> | AsyncGeneratorFunction | Promise<any> | Object): Duplex;
|
|
896
897
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
897
898
|
_writev?(
|
|
898
899
|
chunks: Array<{
|
node/ts4.8/assert.d.ts
CHANGED
|
@@ -65,6 +65,27 @@ declare module 'assert' {
|
|
|
65
65
|
*/
|
|
66
66
|
calls(exact?: number): () => void;
|
|
67
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[];
|
|
68
89
|
/**
|
|
69
90
|
* The arrays contains information about the expected and actual number of calls of
|
|
70
91
|
* the functions that have not been called the expected number of times.
|
|
@@ -100,6 +121,31 @@ declare module 'assert' {
|
|
|
100
121
|
* @return of objects containing information about the wrapper functions returned by `calls`.
|
|
101
122
|
*/
|
|
102
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;
|
|
103
149
|
/**
|
|
104
150
|
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
|
105
151
|
* have not been called the expected number of times.
|
|
@@ -125,6 +171,10 @@ declare module 'assert' {
|
|
|
125
171
|
*/
|
|
126
172
|
verify(): void;
|
|
127
173
|
}
|
|
174
|
+
interface CallTrackerCall {
|
|
175
|
+
thisArg: object;
|
|
176
|
+
arguments: unknown[];
|
|
177
|
+
}
|
|
128
178
|
interface CallTrackerReportInformation {
|
|
129
179
|
message: string;
|
|
130
180
|
/** The actual number of times the function was called. */
|
node/ts4.8/buffer.d.ts
CHANGED
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
*/
|
|
46
46
|
declare module 'buffer' {
|
|
47
47
|
import { BinaryLike } from 'node:crypto';
|
|
48
|
+
import { ReadableStream as WebReadableStream } from 'node:stream/web';
|
|
48
49
|
export const INSPECT_MAX_BYTES: number;
|
|
49
50
|
export const kMaxLength: number;
|
|
50
51
|
export const kStringMaxLength: number;
|
|
@@ -157,13 +158,20 @@ declare module 'buffer' {
|
|
|
157
158
|
*/
|
|
158
159
|
text(): Promise<string>;
|
|
159
160
|
/**
|
|
160
|
-
* Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
|
|
161
|
+
* Returns a new (WHATWG) `ReadableStream` that allows the content of the `Blob` to be read.
|
|
161
162
|
* @since v16.7.0
|
|
162
163
|
*/
|
|
163
|
-
stream():
|
|
164
|
+
stream(): WebReadableStream;
|
|
164
165
|
}
|
|
165
166
|
export import atob = globalThis.atob;
|
|
166
167
|
export import btoa = globalThis.btoa;
|
|
168
|
+
|
|
169
|
+
import { Blob as NodeBlob } from 'buffer';
|
|
170
|
+
// This conditional type will be the existing global Blob in a browser, or
|
|
171
|
+
// the copy below in a Node environment.
|
|
172
|
+
type __Blob = typeof globalThis extends { onmessage: any, Blob: any }
|
|
173
|
+
? {} : NodeBlob;
|
|
174
|
+
|
|
167
175
|
global {
|
|
168
176
|
// Buffer class
|
|
169
177
|
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
|
|
@@ -2231,6 +2239,19 @@ declare module 'buffer' {
|
|
|
2231
2239
|
* @param data An ASCII (Latin1) string.
|
|
2232
2240
|
*/
|
|
2233
2241
|
function btoa(data: string): string;
|
|
2242
|
+
|
|
2243
|
+
interface Blob extends __Blob {}
|
|
2244
|
+
/**
|
|
2245
|
+
* `Blob` class is a global reference for `require('node:buffer').Blob`
|
|
2246
|
+
* https://nodejs.org/api/buffer.html#class-blob
|
|
2247
|
+
* @since v18.0.0
|
|
2248
|
+
*/
|
|
2249
|
+
var Blob: typeof globalThis extends {
|
|
2250
|
+
onmessage: any;
|
|
2251
|
+
Blob: infer T;
|
|
2252
|
+
}
|
|
2253
|
+
? T
|
|
2254
|
+
: typeof NodeBlob;
|
|
2234
2255
|
}
|
|
2235
2256
|
}
|
|
2236
2257
|
declare module 'node:buffer' {
|
node/ts4.8/crypto.d.ts
CHANGED
|
@@ -1830,7 +1830,7 @@ declare module 'crypto' {
|
|
|
1830
1830
|
* Return a random integer `n` such that `min <= n < max`. This
|
|
1831
1831
|
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
|
1832
1832
|
*
|
|
1833
|
-
* The range (`max - min`) must be less than
|
|
1833
|
+
* The range (`max - min`) must be less than 2^48. `min` and `max` must
|
|
1834
1834
|
* be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
|
1835
1835
|
*
|
|
1836
1836
|
* If the `callback` function is not provided, the random integer is
|
|
@@ -3417,7 +3417,7 @@ declare module 'crypto' {
|
|
|
3417
3417
|
interface CheckPrimeOptions {
|
|
3418
3418
|
/**
|
|
3419
3419
|
* The number of Miller-Rabin probabilistic primality iterations to perform.
|
|
3420
|
-
* When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most 2
|
|
3420
|
+
* When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input.
|
|
3421
3421
|
* Care must be used when selecting a number of checks.
|
|
3422
3422
|
* Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
|
|
3423
3423
|
*
|
|
@@ -3723,7 +3723,9 @@ declare module 'crypto' {
|
|
|
3723
3723
|
/**
|
|
3724
3724
|
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
|
3725
3725
|
* `subtle.deriveBits()` attempts to generate `length` bits.
|
|
3726
|
-
* The Node.js implementation requires that `length` is a multiple of `8`.
|
|
3726
|
+
* The Node.js implementation requires that when `length` is a number it must be multiple of `8`.
|
|
3727
|
+
* When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
|
|
3728
|
+
* for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
|
|
3727
3729
|
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
|
3728
3730
|
*
|
|
3729
3731
|
* The algorithms currently supported include:
|
|
@@ -3735,7 +3737,8 @@ declare module 'crypto' {
|
|
|
3735
3737
|
* - `'PBKDF2'`
|
|
3736
3738
|
* @since v15.0.0
|
|
3737
3739
|
*/
|
|
3738
|
-
deriveBits(algorithm:
|
|
3740
|
+
deriveBits(algorithm: EcdhKeyDeriveParams, baseKey: CryptoKey, length: number | null): Promise<ArrayBuffer>;
|
|
3741
|
+
deriveBits(algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
3739
3742
|
/**
|
|
3740
3743
|
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
|
3741
3744
|
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
|
@@ -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/ts4.8/events.d.ts
CHANGED
|
@@ -35,16 +35,53 @@
|
|
|
35
35
|
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
|
|
36
36
|
*/
|
|
37
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
|
+
|
|
38
73
|
interface EventEmitterOptions {
|
|
39
74
|
/**
|
|
40
75
|
* Enables automatic capturing of promise rejection.
|
|
41
76
|
*/
|
|
42
77
|
captureRejections?: boolean | undefined;
|
|
43
78
|
}
|
|
44
|
-
|
|
79
|
+
// Any EventTarget with a Node-style `once` function
|
|
80
|
+
interface _NodeEventTarget {
|
|
45
81
|
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
46
82
|
}
|
|
47
|
-
|
|
83
|
+
// Any EventTarget with a DOM-style `addEventListener`
|
|
84
|
+
interface _DOMEventTarget {
|
|
48
85
|
addEventListener(
|
|
49
86
|
eventName: string,
|
|
50
87
|
listener: (...args: any[]) => void,
|
|
@@ -154,8 +191,8 @@ declare module 'events' {
|
|
|
154
191
|
* ```
|
|
155
192
|
* @since v11.13.0, v10.16.0
|
|
156
193
|
*/
|
|
157
|
-
static once(emitter:
|
|
158
|
-
static once(emitter:
|
|
194
|
+
static once(emitter: _NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
195
|
+
static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
159
196
|
/**
|
|
160
197
|
* ```js
|
|
161
198
|
* const { on, EventEmitter } = require('events');
|
|
@@ -259,7 +296,7 @@ declare module 'events' {
|
|
|
259
296
|
* ```
|
|
260
297
|
* @since v15.2.0, v14.17.0
|
|
261
298
|
*/
|
|
262
|
-
static getEventListeners(emitter:
|
|
299
|
+
static getEventListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
|
263
300
|
/**
|
|
264
301
|
* ```js
|
|
265
302
|
* const {
|
|
@@ -277,7 +314,7 @@ declare module 'events' {
|
|
|
277
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}
|
|
278
315
|
* objects.
|
|
279
316
|
*/
|
|
280
|
-
static setMaxListeners(n?: number, ...eventTargets: Array<
|
|
317
|
+
static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
|
|
281
318
|
/**
|
|
282
319
|
* This symbol shall be used to install a listener for only monitoring `'error'`
|
|
283
320
|
* events. Listeners installed using this symbol are called before the regular
|
node/ts4.8/fs/promises.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ declare module 'fs/promises' {
|
|
|
37
37
|
WriteStream,
|
|
38
38
|
WriteVResult,
|
|
39
39
|
} from 'node:fs';
|
|
40
|
+
import { Interface as ReadlineInterface } from 'node:readline';
|
|
40
41
|
|
|
41
42
|
interface FileChangeInfo<T extends string | Buffer> {
|
|
42
43
|
eventType: WatchEventType;
|
|
@@ -284,6 +285,23 @@ declare module 'fs/promises' {
|
|
|
284
285
|
| BufferEncoding
|
|
285
286
|
| null
|
|
286
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;
|
|
287
305
|
/**
|
|
288
306
|
* @since v10.0.0
|
|
289
307
|
* @return Fulfills with an {fs.Stats} for the file.
|
node/ts4.8/globals.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ interface AbortController {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
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 {
|
|
60
|
+
interface AbortSignal extends EventTarget {
|
|
61
61
|
/**
|
|
62
62
|
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
|
63
63
|
*/
|