@types/node 15.0.2 → 15.6.0
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/async_hooks.d.ts +2 -2
- node/child_process.d.ts +19 -8
- node/crypto.d.ts +186 -0
- node/diagnostic_channel.d.ts +34 -0
- node/events.d.ts +11 -0
- node/fs/promises.d.ts +6 -5
- node/fs.d.ts +43 -34
- node/globals.d.ts +4 -0
- node/http.d.ts +4 -2
- node/http2.d.ts +11 -6
- node/index.d.ts +1 -1
- node/net.d.ts +6 -4
- node/package.json +2 -2
- node/path.d.ts +10 -0
- node/perf_hooks.d.ts +7 -4
- node/process.d.ts +13 -1
- node/readline.d.ts +1 -0
- node/repl.d.ts +3 -3
- node/stream.d.ts +21 -13
- node/tls.d.ts +3 -0
- node/ts3.6/base.d.ts +2 -0
- node/util/types.d.ts +53 -0
- node/util.d.ts +68 -119
- node/v8.d.ts +11 -0
- node/vm.d.ts +1 -1
- node/worker_threads.d.ts +26 -3
node/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (http://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Fri, 21 May 2021 10:32:02 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `Buffer`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
|
14
14
|
|
node/async_hooks.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ declare module 'async_hooks' {
|
|
|
85
85
|
interface AsyncResourceOptions {
|
|
86
86
|
/**
|
|
87
87
|
* The ID of the execution context that created this async event.
|
|
88
|
-
*
|
|
88
|
+
* @default executionAsyncId()
|
|
89
89
|
*/
|
|
90
90
|
triggerAsyncId?: number;
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@ declare module 'async_hooks' {
|
|
|
94
94
|
* This usually does not need to be set (even if `emitDestroy` is called
|
|
95
95
|
* manually), unless the resource's `asyncId` is retrieved and the
|
|
96
96
|
* sensitive API's `emitDestroy` is called with it.
|
|
97
|
-
*
|
|
97
|
+
* @default false
|
|
98
98
|
*/
|
|
99
99
|
requireManualDestroy?: boolean;
|
|
100
100
|
}
|
node/child_process.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
declare module 'child_process' {
|
|
2
2
|
import { BaseEncodingOptions } from 'fs';
|
|
3
|
-
import
|
|
3
|
+
import { EventEmitter, Abortable } from 'events';
|
|
4
4
|
import * as net from 'net';
|
|
5
5
|
import { Writable, Readable, Stream, Pipe } from 'stream';
|
|
6
6
|
|
|
7
7
|
type Serializable = string | object | number | boolean;
|
|
8
8
|
type SendHandle = net.Socket | net.Server;
|
|
9
9
|
|
|
10
|
-
interface ChildProcess extends
|
|
10
|
+
interface ChildProcess extends EventEmitter {
|
|
11
11
|
stdin: Writable | null;
|
|
12
12
|
stdout: Readable | null;
|
|
13
13
|
stderr: Readable | null;
|
|
@@ -41,6 +41,7 @@ declare module 'child_process' {
|
|
|
41
41
|
* 3. error
|
|
42
42
|
* 4. exit
|
|
43
43
|
* 5. message
|
|
44
|
+
* 6. spawn
|
|
44
45
|
*/
|
|
45
46
|
|
|
46
47
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
@@ -49,6 +50,7 @@ declare module 'child_process' {
|
|
|
49
50
|
addListener(event: "error", listener: (err: Error) => void): this;
|
|
50
51
|
addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
51
52
|
addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
|
53
|
+
addListener(event: "spawn", listener: () => void): this;
|
|
52
54
|
|
|
53
55
|
emit(event: string | symbol, ...args: any[]): boolean;
|
|
54
56
|
emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean;
|
|
@@ -56,6 +58,7 @@ declare module 'child_process' {
|
|
|
56
58
|
emit(event: "error", err: Error): boolean;
|
|
57
59
|
emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
|
|
58
60
|
emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
|
|
61
|
+
emit(event: "spawn", listener: () => void): boolean;
|
|
59
62
|
|
|
60
63
|
on(event: string, listener: (...args: any[]) => void): this;
|
|
61
64
|
on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
@@ -63,6 +66,7 @@ declare module 'child_process' {
|
|
|
63
66
|
on(event: "error", listener: (err: Error) => void): this;
|
|
64
67
|
on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
65
68
|
on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
|
69
|
+
on(event: "spawn", listener: () => void): this;
|
|
66
70
|
|
|
67
71
|
once(event: string, listener: (...args: any[]) => void): this;
|
|
68
72
|
once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
@@ -70,6 +74,7 @@ declare module 'child_process' {
|
|
|
70
74
|
once(event: "error", listener: (err: Error) => void): this;
|
|
71
75
|
once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
72
76
|
once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
|
77
|
+
once(event: "spawn", listener: () => void): this;
|
|
73
78
|
|
|
74
79
|
prependListener(event: string, listener: (...args: any[]) => void): this;
|
|
75
80
|
prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
@@ -77,6 +82,7 @@ declare module 'child_process' {
|
|
|
77
82
|
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
78
83
|
prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
79
84
|
prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
|
85
|
+
prependListener(event: "spawn", listener: () => void): this;
|
|
80
86
|
|
|
81
87
|
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
|
82
88
|
prependOnceListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
@@ -84,6 +90,7 @@ declare module 'child_process' {
|
|
|
84
90
|
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
85
91
|
prependOnceListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
86
92
|
prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
|
93
|
+
prependOnceListener(event: "spawn", listener: () => void): this;
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
// return this object when stdio option is undefined or not specified
|
|
@@ -122,7 +129,9 @@ declare module 'child_process' {
|
|
|
122
129
|
keepOpen?: boolean;
|
|
123
130
|
}
|
|
124
131
|
|
|
125
|
-
type
|
|
132
|
+
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
|
133
|
+
|
|
134
|
+
type StdioOptions = IOType | Array<(IOType | "ipc" | Stream | number | null | undefined)>;
|
|
126
135
|
|
|
127
136
|
type SerializationType = 'json' | 'advanced';
|
|
128
137
|
|
|
@@ -152,7 +161,7 @@ declare module 'child_process' {
|
|
|
152
161
|
timeout?: number;
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
interface CommonSpawnOptions extends CommonOptions, MessagingOptions {
|
|
164
|
+
interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
|
|
156
165
|
argv0?: string;
|
|
157
166
|
stdio?: StdioOptions;
|
|
158
167
|
shell?: boolean | string;
|
|
@@ -164,11 +173,12 @@ declare module 'child_process' {
|
|
|
164
173
|
}
|
|
165
174
|
|
|
166
175
|
interface SpawnOptionsWithoutStdio extends SpawnOptions {
|
|
167
|
-
stdio?:
|
|
176
|
+
stdio?: StdioPipeNamed | StdioPipe[];
|
|
168
177
|
}
|
|
169
178
|
|
|
170
179
|
type StdioNull = 'inherit' | 'ignore' | Stream;
|
|
171
|
-
type
|
|
180
|
+
type StdioPipeNamed = 'pipe' | 'overlapped';
|
|
181
|
+
type StdioPipe = undefined | null | StdioPipeNamed;
|
|
172
182
|
|
|
173
183
|
interface SpawnOptionsWithStdioTuple<
|
|
174
184
|
Stdin extends StdioNull | StdioPipe,
|
|
@@ -323,11 +333,12 @@ declare module 'child_process' {
|
|
|
323
333
|
function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
|
|
324
334
|
}
|
|
325
335
|
|
|
326
|
-
interface ExecFileOptions extends CommonOptions {
|
|
336
|
+
interface ExecFileOptions extends CommonOptions, Abortable {
|
|
327
337
|
maxBuffer?: number;
|
|
328
338
|
killSignal?: NodeJS.Signals | number;
|
|
329
339
|
windowsVerbatimArguments?: boolean;
|
|
330
340
|
shell?: boolean | string;
|
|
341
|
+
signal?: AbortSignal;
|
|
331
342
|
}
|
|
332
343
|
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
|
|
333
344
|
encoding: BufferEncoding;
|
|
@@ -427,7 +438,7 @@ declare module 'child_process' {
|
|
|
427
438
|
): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
|
|
428
439
|
}
|
|
429
440
|
|
|
430
|
-
interface ForkOptions extends ProcessEnvOptions, MessagingOptions {
|
|
441
|
+
interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
|
|
431
442
|
execPath?: string;
|
|
432
443
|
execArgv?: string[];
|
|
433
444
|
silent?: boolean;
|
node/crypto.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare module 'crypto' {
|
|
2
2
|
import * as stream from 'stream';
|
|
3
|
+
import { PeerCertificate } from 'tls';
|
|
3
4
|
|
|
4
5
|
interface Certificate {
|
|
5
6
|
/**
|
|
@@ -1267,4 +1268,189 @@ declare module 'crypto' {
|
|
|
1267
1268
|
* or if the derived key cannot be generated.
|
|
1268
1269
|
*/
|
|
1269
1270
|
function hkdfSync(digest: string, key: BinaryLike | KeyObject, salt: BinaryLike, info: BinaryLike, keylen: number): ArrayBuffer;
|
|
1271
|
+
|
|
1272
|
+
interface SecureHeapUsage {
|
|
1273
|
+
/**
|
|
1274
|
+
* The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
|
|
1275
|
+
*/
|
|
1276
|
+
total: number;
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
|
|
1280
|
+
*/
|
|
1281
|
+
min: number;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* The total number of bytes currently allocated from the secure heap.
|
|
1285
|
+
*/
|
|
1286
|
+
used: number;
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* The calculated ratio of `used` to `total` allocated bytes.
|
|
1290
|
+
*/
|
|
1291
|
+
utilization: number;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
function secureHeapUsed(): SecureHeapUsage;
|
|
1295
|
+
|
|
1296
|
+
// TODO: X509Certificate
|
|
1297
|
+
|
|
1298
|
+
interface RandomUUIDOptions {
|
|
1299
|
+
/**
|
|
1300
|
+
* By default, to improve performance,
|
|
1301
|
+
* Node.js will pre-emptively generate and persistently cache enough
|
|
1302
|
+
* random data to generate up to 128 random UUIDs. To generate a UUID
|
|
1303
|
+
* without using the cache, set `disableEntropyCache` to `true`.
|
|
1304
|
+
*
|
|
1305
|
+
* @default `false`
|
|
1306
|
+
*/
|
|
1307
|
+
disableEntropyCache?: boolean;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function randomUUID(options?: RandomUUIDOptions): string;
|
|
1311
|
+
|
|
1312
|
+
interface X509CheckOptions {
|
|
1313
|
+
/**
|
|
1314
|
+
* @default 'always'
|
|
1315
|
+
*/
|
|
1316
|
+
subject: 'always' | 'never';
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* @default true
|
|
1320
|
+
*/
|
|
1321
|
+
wildcards: boolean;
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* @default true
|
|
1325
|
+
*/
|
|
1326
|
+
partialWildcards: boolean;
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* @default false
|
|
1330
|
+
*/
|
|
1331
|
+
multiLabelWildcards: boolean;
|
|
1332
|
+
|
|
1333
|
+
/**
|
|
1334
|
+
* @default false
|
|
1335
|
+
*/
|
|
1336
|
+
singleLabelSubdomains: boolean;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
class X509Certificate {
|
|
1340
|
+
/**
|
|
1341
|
+
* Will be `true` if this is a Certificate Authority (ca) certificate.
|
|
1342
|
+
*/
|
|
1343
|
+
readonly ca: boolean;
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* The SHA-1 fingerprint of this certificate.
|
|
1347
|
+
*/
|
|
1348
|
+
readonly fingerprint: string;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* The SHA-256 fingerprint of this certificate.
|
|
1352
|
+
*/
|
|
1353
|
+
readonly fingerprint256: string;
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* The complete subject of this certificate.
|
|
1357
|
+
*/
|
|
1358
|
+
readonly subject: string;
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* The subject alternative name specified for this certificate.
|
|
1362
|
+
*/
|
|
1363
|
+
readonly subjectAltName: string;
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* The information access content of this certificate.
|
|
1367
|
+
*/
|
|
1368
|
+
readonly infoAccess: string;
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* An array detailing the key usages for this certificate.
|
|
1372
|
+
*/
|
|
1373
|
+
readonly keyUsage: string[];
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* The public key for this certificate.
|
|
1377
|
+
*/
|
|
1378
|
+
readonly publicKey: KeyObject;
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* A `Buffer` containing the DER encoding of this certificate.
|
|
1382
|
+
*/
|
|
1383
|
+
readonly raw: Buffer;
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* The serial number of this certificate.
|
|
1387
|
+
*/
|
|
1388
|
+
readonly serialNumber: string;
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Returns the PEM-encoded certificate.
|
|
1392
|
+
*/
|
|
1393
|
+
readonly validFrom: string;
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* The date/time from which this certificate is considered valid.
|
|
1397
|
+
*/
|
|
1398
|
+
readonly validTo: string;
|
|
1399
|
+
|
|
1400
|
+
constructor(buffer: BinaryLike);
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Checks whether the certificate matches the given email address.
|
|
1404
|
+
*
|
|
1405
|
+
* Returns `email` if the certificate matches,`undefined` if it does not.
|
|
1406
|
+
*/
|
|
1407
|
+
checkEmail(email: string, options?: X509CheckOptions): string | undefined;
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* Checks whether the certificate matches the given host name.
|
|
1411
|
+
*
|
|
1412
|
+
* Returns `name` if the certificate matches, `undefined` if it does not.
|
|
1413
|
+
*/
|
|
1414
|
+
checkHost(name: string, options?: X509CheckOptions): string | undefined;
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Checks whether the certificate matches the given IP address (IPv4 or IPv6).
|
|
1418
|
+
*
|
|
1419
|
+
* Returns `ip` if the certificate matches, `undefined` if it does not.
|
|
1420
|
+
*/
|
|
1421
|
+
checkIP(ip: string, options?: X509CheckOptions): string | undefined;
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Checks whether this certificate was issued by the given `otherCert`.
|
|
1425
|
+
*/
|
|
1426
|
+
checkIssued(otherCert: X509Certificate): boolean;
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Checks whether this certificate was issued by the given `otherCert`.
|
|
1430
|
+
*/
|
|
1431
|
+
checkPrivateKey(privateKey: KeyObject): boolean;
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* There is no standard JSON encoding for X509 certificates. The
|
|
1435
|
+
* `toJSON()` method returns a string containing the PEM encoded
|
|
1436
|
+
* certificate.
|
|
1437
|
+
*/
|
|
1438
|
+
toJSON(): string;
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Returns information about this certificate using the legacy [certificate object][] encoding.
|
|
1442
|
+
*/
|
|
1443
|
+
toLegacyObject(): PeerCertificate;
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* Returns the PEM-encoded certificate.
|
|
1447
|
+
*/
|
|
1448
|
+
toString(): string;
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Verifies that this certificate was signed by the given public key.
|
|
1452
|
+
* Does not perform any other validation checks on the certificate.
|
|
1453
|
+
*/
|
|
1454
|
+
verify(publicKey: KeyObject): boolean;
|
|
1455
|
+
}
|
|
1270
1456
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @experimental
|
|
3
|
+
*/
|
|
4
|
+
declare module 'diagnostic_channel' {
|
|
5
|
+
/**
|
|
6
|
+
* Returns wether a named channel has subscribers or not.
|
|
7
|
+
*/
|
|
8
|
+
function hasSubscribers(name: string): boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Gets or create a diagnostic channel by name.
|
|
12
|
+
*/
|
|
13
|
+
function channel(name: string): Channel;
|
|
14
|
+
|
|
15
|
+
type ChannelListener = (name: string, message: unknown) => void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Simple diagnostic channel that allows
|
|
19
|
+
*/
|
|
20
|
+
class Channel {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly hashSubscribers: boolean;
|
|
23
|
+
private constructor(name: string);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Add a listener to the message channel.
|
|
27
|
+
*/
|
|
28
|
+
subscribe(listener: ChannelListener): void;
|
|
29
|
+
/**
|
|
30
|
+
* Removes a previously registered listener.
|
|
31
|
+
*/
|
|
32
|
+
unsubscribe(listener: ChannelListener): void;
|
|
33
|
+
}
|
|
34
|
+
}
|
node/events.d.ts
CHANGED
|
@@ -28,6 +28,10 @@ declare module 'events' {
|
|
|
28
28
|
|
|
29
29
|
/** @deprecated since v4.0.0 */
|
|
30
30
|
static listenerCount(emitter: NodeJS.EventEmitter, event: string | symbol): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a list listener for a specific emitter event name.
|
|
33
|
+
*/
|
|
34
|
+
static getEventListener(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* This symbol shall be used to install a listener for only monitoring `'error'`
|
|
@@ -53,6 +57,13 @@ declare module 'events' {
|
|
|
53
57
|
namespace EventEmitter {
|
|
54
58
|
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
|
55
59
|
export { internal as EventEmitter };
|
|
60
|
+
|
|
61
|
+
export interface Abortable {
|
|
62
|
+
/**
|
|
63
|
+
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
|
64
|
+
*/
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}
|
|
56
67
|
}
|
|
57
68
|
|
|
58
69
|
global {
|
node/fs/promises.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare module 'fs/promises' {
|
|
2
|
+
import { Abortable } from 'events';
|
|
2
3
|
import {
|
|
3
4
|
Stats,
|
|
4
5
|
BigIntStats,
|
|
@@ -143,7 +144,7 @@ declare module 'fs/promises' {
|
|
|
143
144
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
144
145
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
145
146
|
*/
|
|
146
|
-
writeFile(data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode, flag?: OpenMode } | BufferEncoding | null): Promise<void>;
|
|
147
|
+
writeFile(data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode, flag?: OpenMode } & Abortable | BufferEncoding | null): Promise<void>;
|
|
147
148
|
|
|
148
149
|
/**
|
|
149
150
|
* See `fs.writev` promisified version.
|
|
@@ -510,7 +511,7 @@ declare module 'fs/promises' {
|
|
|
510
511
|
* If `mode` is a string, it is parsed as an octal integer.
|
|
511
512
|
* If `flag` is not supplied, the default of `'w'` is used.
|
|
512
513
|
*/
|
|
513
|
-
function writeFile(path: PathLike | FileHandle, data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode, flag?: OpenMode } | BufferEncoding | null): Promise<void>;
|
|
514
|
+
function writeFile(path: PathLike | FileHandle, data: string | Uint8Array, options?: BaseEncodingOptions & { mode?: Mode, flag?: OpenMode } & Abortable | BufferEncoding | null): Promise<void>;
|
|
514
515
|
|
|
515
516
|
/**
|
|
516
517
|
* Asynchronously append data to a file, creating the file if it does not exist.
|
|
@@ -533,7 +534,7 @@ declare module 'fs/promises' {
|
|
|
533
534
|
* @param options An object that may contain an optional flag.
|
|
534
535
|
* If a flag is not provided, it defaults to `'r'`.
|
|
535
536
|
*/
|
|
536
|
-
function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: OpenMode } | null): Promise<Buffer>;
|
|
537
|
+
function readFile(path: PathLike | FileHandle, options?: { encoding?: null, flag?: OpenMode } & Abortable | null): Promise<Buffer>;
|
|
537
538
|
|
|
538
539
|
/**
|
|
539
540
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -542,7 +543,7 @@ declare module 'fs/promises' {
|
|
|
542
543
|
* @param options An object that may contain an optional flag.
|
|
543
544
|
* If a flag is not provided, it defaults to `'r'`.
|
|
544
545
|
*/
|
|
545
|
-
function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: OpenMode } | BufferEncoding): Promise<string>;
|
|
546
|
+
function readFile(path: PathLike | FileHandle, options: { encoding: BufferEncoding, flag?: OpenMode } & Abortable | BufferEncoding): Promise<string>;
|
|
546
547
|
|
|
547
548
|
/**
|
|
548
549
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -551,7 +552,7 @@ declare module 'fs/promises' {
|
|
|
551
552
|
* @param options An object that may contain an optional flag.
|
|
552
553
|
* If a flag is not provided, it defaults to `'r'`.
|
|
553
554
|
*/
|
|
554
|
-
function readFile(path: PathLike | FileHandle, options?: BaseEncodingOptions & { flag?: OpenMode } | BufferEncoding | null): Promise<string | Buffer>;
|
|
555
|
+
function readFile(path: PathLike | FileHandle, options?: BaseEncodingOptions & Abortable & { flag?: OpenMode } | BufferEncoding | null): Promise<string | Buffer>;
|
|
555
556
|
|
|
556
557
|
function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
|
|
557
558
|
}
|
node/fs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare module 'fs' {
|
|
2
2
|
import * as stream from 'stream';
|
|
3
|
-
import EventEmitter
|
|
3
|
+
import { Abortable, EventEmitter } from 'events';
|
|
4
4
|
import { URL } from 'url';
|
|
5
5
|
import * as promises from 'fs/promises';
|
|
6
6
|
|
|
@@ -552,13 +552,21 @@ declare module 'fs' {
|
|
|
552
552
|
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
+
export interface StatSyncFn<TDescriptor = PathLike> extends Function {
|
|
556
|
+
(path: TDescriptor, options?: undefined): Stats;
|
|
557
|
+
(path: TDescriptor, options?: StatOptions & { bigint?: false; throwIfNoEntry: false }): Stats | undefined;
|
|
558
|
+
(path: TDescriptor, options: StatOptions & { bigint: true; throwIfNoEntry: false }): BigIntStats | undefined;
|
|
559
|
+
(path: TDescriptor, options?: StatOptions & { bigint?: false }): Stats;
|
|
560
|
+
(path: TDescriptor, options: StatOptions & { bigint: true }): BigIntStats;
|
|
561
|
+
(path: TDescriptor, options: StatOptions & { bigint: boolean; throwIfNoEntry?: false }): Stats | BigIntStats;
|
|
562
|
+
(path: TDescriptor, options?: StatOptions): Stats | BigIntStats | undefined;
|
|
563
|
+
}
|
|
564
|
+
|
|
555
565
|
/**
|
|
556
566
|
* Synchronous stat(2) - Get file status.
|
|
557
567
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
558
568
|
*/
|
|
559
|
-
export
|
|
560
|
-
export function statSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats;
|
|
561
|
-
export function statSync(path: PathLike, options?: StatOptions): Stats | BigIntStats;
|
|
569
|
+
export const statSync: StatSyncFn;
|
|
562
570
|
|
|
563
571
|
/**
|
|
564
572
|
* Asynchronous fstat(2) - Get file status.
|
|
@@ -584,9 +592,7 @@ declare module 'fs' {
|
|
|
584
592
|
* Synchronous fstat(2) - Get file status.
|
|
585
593
|
* @param fd A file descriptor.
|
|
586
594
|
*/
|
|
587
|
-
export
|
|
588
|
-
export function fstatSync(fd: number, options: StatOptions & { bigint: true }): BigIntStats;
|
|
589
|
-
export function fstatSync(fd: number, options?: StatOptions): Stats | BigIntStats;
|
|
595
|
+
export const fstatSync: StatSyncFn<number>;
|
|
590
596
|
|
|
591
597
|
/**
|
|
592
598
|
* Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
@@ -612,10 +618,7 @@ declare module 'fs' {
|
|
|
612
618
|
* Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
|
|
613
619
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
614
620
|
*/
|
|
615
|
-
export
|
|
616
|
-
export function lstatSync(path: PathLike, options: StatOptions & { bigint: true }): BigIntStats;
|
|
617
|
-
export function lstatSync(path: PathLike, options?: StatOptions): Stats | BigIntStats;
|
|
618
|
-
|
|
621
|
+
export const lstatSync: StatSyncFn;
|
|
619
622
|
/**
|
|
620
623
|
* Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.
|
|
621
624
|
* @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1557,7 +1560,11 @@ declare module 'fs' {
|
|
|
1557
1560
|
* @param options An object that may contain an optional flag.
|
|
1558
1561
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1559
1562
|
*/
|
|
1560
|
-
export function readFile(
|
|
1563
|
+
export function readFile(
|
|
1564
|
+
path: PathLike | number,
|
|
1565
|
+
options: { encoding?: null; flag?: string; } & Abortable | undefined | null,
|
|
1566
|
+
callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void,
|
|
1567
|
+
): void;
|
|
1561
1568
|
|
|
1562
1569
|
/**
|
|
1563
1570
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -1567,7 +1574,11 @@ declare module 'fs' {
|
|
|
1567
1574
|
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
1568
1575
|
* If a flag is not provided, it defaults to `'r'`.
|
|
1569
1576
|
*/
|
|
1570
|
-
export function readFile(
|
|
1577
|
+
export function readFile(
|
|
1578
|
+
path: PathLike | number,
|
|
1579
|
+
options: { encoding: BufferEncoding; flag?: string; } & Abortable | string,
|
|
1580
|
+
callback: (err: NodeJS.ErrnoException | null, data: string) => void,
|
|
1581
|
+
): void;
|
|
1571
1582
|
|
|
1572
1583
|
/**
|
|
1573
1584
|
* Asynchronously reads the entire contents of a file.
|
|
@@ -1579,7 +1590,8 @@ declare module 'fs' {
|
|
|
1579
1590
|
*/
|
|
1580
1591
|
export function readFile(
|
|
1581
1592
|
path: PathLike | number,
|
|
1582
|
-
|
|
1593
|
+
// TODO: unify the options across all readfile functions
|
|
1594
|
+
options: BaseEncodingOptions & { flag?: string; } & Abortable | string | undefined | null,
|
|
1583
1595
|
callback: (err: NodeJS.ErrnoException | null, data: string | Buffer) => void,
|
|
1584
1596
|
): void;
|
|
1585
1597
|
|
|
@@ -1651,7 +1663,7 @@ declare module 'fs' {
|
|
|
1651
1663
|
*/
|
|
1652
1664
|
export function readFileSync(path: PathLike | number, options?: BaseEncodingOptions & { flag?: string; } | BufferEncoding | null): string | Buffer;
|
|
1653
1665
|
|
|
1654
|
-
export type WriteFileOptions = BaseEncodingOptions & { mode?: Mode; flag?: string; } | string | null;
|
|
1666
|
+
export type WriteFileOptions = (BaseEncodingOptions & Abortable & { mode?: Mode; flag?: string; }) | string | null;
|
|
1655
1667
|
|
|
1656
1668
|
/**
|
|
1657
1669
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
@@ -2050,15 +2062,10 @@ declare module 'fs' {
|
|
|
2050
2062
|
*/
|
|
2051
2063
|
export function accessSync(path: PathLike, mode?: number): void;
|
|
2052
2064
|
|
|
2053
|
-
|
|
2054
|
-
* Returns a new `ReadStream` object.
|
|
2055
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
2056
|
-
* URL support is _experimental_.
|
|
2057
|
-
*/
|
|
2058
|
-
export function createReadStream(path: PathLike, options?: string | {
|
|
2065
|
+
interface StreamOptions {
|
|
2059
2066
|
flags?: string;
|
|
2060
2067
|
encoding?: BufferEncoding;
|
|
2061
|
-
fd?: number;
|
|
2068
|
+
fd?: number | promises.FileHandle;
|
|
2062
2069
|
mode?: number;
|
|
2063
2070
|
autoClose?: boolean;
|
|
2064
2071
|
/**
|
|
@@ -2066,25 +2073,26 @@ declare module 'fs' {
|
|
|
2066
2073
|
*/
|
|
2067
2074
|
emitClose?: boolean;
|
|
2068
2075
|
start?: number;
|
|
2069
|
-
end?: number;
|
|
2070
2076
|
highWaterMark?: number;
|
|
2071
|
-
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
interface ReadStreamOptions extends StreamOptions {
|
|
2080
|
+
end?: number;
|
|
2081
|
+
}
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* Returns a new `ReadStream` object.
|
|
2085
|
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
2086
|
+
* URL support is _experimental_.
|
|
2087
|
+
*/
|
|
2088
|
+
export function createReadStream(path: PathLike, options?: string | ReadStreamOptions): ReadStream;
|
|
2072
2089
|
|
|
2073
2090
|
/**
|
|
2074
2091
|
* Returns a new `WriteStream` object.
|
|
2075
2092
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
2076
2093
|
* URL support is _experimental_.
|
|
2077
2094
|
*/
|
|
2078
|
-
export function createWriteStream(path: PathLike, options?: string |
|
|
2079
|
-
flags?: string;
|
|
2080
|
-
encoding?: BufferEncoding;
|
|
2081
|
-
fd?: number;
|
|
2082
|
-
mode?: number;
|
|
2083
|
-
autoClose?: boolean;
|
|
2084
|
-
emitClose?: boolean;
|
|
2085
|
-
start?: number;
|
|
2086
|
-
highWaterMark?: number;
|
|
2087
|
-
}): WriteStream;
|
|
2095
|
+
export function createWriteStream(path: PathLike, options?: string | StreamOptions): WriteStream;
|
|
2088
2096
|
|
|
2089
2097
|
/**
|
|
2090
2098
|
* Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
|
|
@@ -2253,5 +2261,6 @@ declare module 'fs' {
|
|
|
2253
2261
|
|
|
2254
2262
|
export interface StatOptions {
|
|
2255
2263
|
bigint?: boolean;
|
|
2264
|
+
throwIfNoEntry?: boolean;
|
|
2256
2265
|
}
|
|
2257
2266
|
}
|
node/globals.d.ts
CHANGED
|
@@ -622,6 +622,10 @@ declare namespace NodeJS {
|
|
|
622
622
|
'.node': (m: Module, filename: string) => any;
|
|
623
623
|
}
|
|
624
624
|
interface Module {
|
|
625
|
+
/**
|
|
626
|
+
* `true` if the module is running during the Node.js preload
|
|
627
|
+
*/
|
|
628
|
+
isPreloading: boolean;
|
|
625
629
|
exports: any;
|
|
626
630
|
require: Require;
|
|
627
631
|
id: string;
|
node/http.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ declare module 'http' {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
interface ClientRequestArgs {
|
|
80
|
+
abort?: AbortSignal;
|
|
80
81
|
protocol?: string | null;
|
|
81
82
|
host?: string | null;
|
|
82
83
|
hostname?: string | null;
|
|
@@ -174,7 +175,7 @@ declare module 'http' {
|
|
|
174
175
|
constructor();
|
|
175
176
|
|
|
176
177
|
setTimeout(msecs: number, callback?: () => void): this;
|
|
177
|
-
setHeader(name: string, value: number | string | ReadonlyArray<string>):
|
|
178
|
+
setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
|
|
178
179
|
getHeader(name: string): number | string | string[] | undefined;
|
|
179
180
|
getHeaders(): OutgoingHttpHeaders;
|
|
180
181
|
getHeaderNames(): string[];
|
|
@@ -373,7 +374,8 @@ declare module 'http' {
|
|
|
373
374
|
*/
|
|
374
375
|
timeout?: number;
|
|
375
376
|
/**
|
|
376
|
-
* Scheduling strategy to apply when picking the next free socket to use.
|
|
377
|
+
* Scheduling strategy to apply when picking the next free socket to use.
|
|
378
|
+
* @default `lifo`
|
|
377
379
|
*/
|
|
378
380
|
scheduling?: 'fifo' | 'lifo';
|
|
379
381
|
}
|