@types/node 12.7.10 → 12.11.1

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 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: Thu, 03 Oct 2019 16:38:17 GMT
11
+ * Last updated: Tue, 15 Oct 2019 23:57:18 GMT
12
12
  * Dependencies: none
13
13
  * Global values: Buffer, NodeJS, Symbol, __dirname, __filename, clearImmediate, clearInterval, clearTimeout, console, exports, global, module, process, queueMicrotask, require, setImmediate, setInterval, setTimeout
14
14
 
node/child_process.d.ts CHANGED
@@ -404,7 +404,7 @@ declare module "child_process" {
404
404
 
405
405
  interface SpawnSyncOptions extends CommonOptions {
406
406
  argv0?: string; // Not specified in the docs
407
- input?: string | NodeJS.TypedArray | DataView;
407
+ input?: string | NodeJS.ArrayBufferView;
408
408
  stdio?: StdioOptions;
409
409
  killSignal?: string | number;
410
410
  maxBuffer?: number;
@@ -455,7 +455,7 @@ declare module "child_process" {
455
455
  function execSync(command: string, options?: ExecSyncOptions): Buffer;
456
456
 
457
457
  interface ExecFileSyncOptions extends CommonOptions {
458
- input?: string | NodeJS.TypedArray | DataView;
458
+ input?: string | NodeJS.ArrayBufferView;
459
459
  stdio?: StdioOptions;
460
460
  killSignal?: string | number;
461
461
  maxBuffer?: number;
node/crypto.d.ts CHANGED
@@ -4,7 +4,7 @@ declare module "crypto" {
4
4
  interface Certificate {
5
5
  exportChallenge(spkac: BinaryLike): Buffer;
6
6
  exportPublicKey(spkac: BinaryLike): Buffer;
7
- verifySpkac(spkac: Binary): boolean;
7
+ verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
8
8
  }
9
9
  const Certificate: {
10
10
  new(): Certificate;
@@ -106,10 +106,18 @@ declare module "crypto" {
106
106
  const defaultCipherList: string;
107
107
  }
108
108
 
109
+ interface HashOptions extends stream.TransformOptions {
110
+ /**
111
+ * For XOF hash functions such as `shake256`, the
112
+ * outputLength option can be used to specify the desired output length in bytes.
113
+ */
114
+ outputLength?: number;
115
+ }
116
+
109
117
  /** @deprecated since v10.0.0 */
110
118
  const fips: boolean;
111
119
 
112
- function createHash(algorithm: string, options?: stream.TransformOptions): Hash;
120
+ function createHash(algorithm: string, options?: HashOptions): Hash;
113
121
  function createHmac(algorithm: string, key: BinaryLike, options?: stream.TransformOptions): Hmac;
114
122
 
115
123
  type Utf8AsciiLatin1Encoding = "utf8" | "ascii" | "latin1";
@@ -159,8 +167,7 @@ declare module "crypto" {
159
167
  type CipherCCMTypes = 'aes-128-ccm' | 'aes-192-ccm' | 'aes-256-ccm';
160
168
  type CipherGCMTypes = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
161
169
 
162
- type Binary = NodeJS.TypedArray | DataView;
163
- type BinaryLike = string | Binary;
170
+ type BinaryLike = string | NodeJS.ArrayBufferView;
164
171
 
165
172
  type CipherKey = BinaryLike | KeyObject;
166
173
 
@@ -197,7 +204,7 @@ declare module "crypto" {
197
204
  private constructor();
198
205
  update(data: BinaryLike): Buffer;
199
206
  update(data: string, input_encoding: Utf8AsciiBinaryEncoding): Buffer;
200
- update(data: Binary, input_encoding: undefined, output_encoding: HexBase64BinaryEncoding): string;
207
+ update(data: NodeJS.ArrayBufferView, input_encoding: undefined, output_encoding: HexBase64BinaryEncoding): string;
201
208
  update(data: string, input_encoding: Utf8AsciiBinaryEncoding | undefined, output_encoding: HexBase64BinaryEncoding): string;
202
209
  final(): Buffer;
203
210
  final(output_encoding: string): string;
@@ -236,23 +243,23 @@ declare module "crypto" {
236
243
 
237
244
  class Decipher extends stream.Transform {
238
245
  private constructor();
239
- update(data: Binary): Buffer;
246
+ update(data: NodeJS.ArrayBufferView): Buffer;
240
247
  update(data: string, input_encoding: HexBase64BinaryEncoding): Buffer;
241
- update(data: Binary, input_encoding: undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
248
+ update(data: NodeJS.ArrayBufferView, input_encoding: undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
242
249
  update(data: string, input_encoding: HexBase64BinaryEncoding | undefined, output_encoding: Utf8AsciiBinaryEncoding): string;
243
250
  final(): Buffer;
244
251
  final(output_encoding: string): string;
245
252
  setAutoPadding(auto_padding?: boolean): this;
246
- // setAuthTag(tag: Binary): this;
247
- // setAAD(buffer: Binary): this;
253
+ // setAuthTag(tag: NodeJS.ArrayBufferView): this;
254
+ // setAAD(buffer: NodeJS.ArrayBufferView): this;
248
255
  }
249
256
  interface DecipherCCM extends Decipher {
250
- setAuthTag(buffer: Binary): this;
251
- setAAD(buffer: Binary, options: { plaintextLength: number }): this;
257
+ setAuthTag(buffer: NodeJS.ArrayBufferView): this;
258
+ setAAD(buffer: NodeJS.ArrayBufferView, options: { plaintextLength: number }): this;
252
259
  }
253
260
  interface DecipherGCM extends Decipher {
254
- setAuthTag(buffer: Binary): this;
255
- setAAD(buffer: Binary, options?: { plaintextLength: number }): this;
261
+ setAuthTag(buffer: NodeJS.ArrayBufferView): this;
262
+ setAAD(buffer: NodeJS.ArrayBufferView, options?: { plaintextLength: number }): this;
256
263
  }
257
264
 
258
265
  interface PrivateKeyInput {
@@ -302,23 +309,23 @@ declare module "crypto" {
302
309
 
303
310
  update(data: BinaryLike): Verify;
304
311
  update(data: string, input_encoding: Utf8AsciiLatin1Encoding): Verify;
305
- verify(object: Object | KeyLike, signature: Binary): boolean;
312
+ verify(object: Object | KeyLike, signature: NodeJS.ArrayBufferView): boolean;
306
313
  verify(object: Object | KeyLike, signature: string, signature_format?: HexBase64Latin1Encoding): boolean;
307
314
  // https://nodejs.org/api/crypto.html#crypto_verifier_verify_object_signature_signature_format
308
315
  // The signature field accepts a TypedArray type, but it is only available starting ES2017
309
316
  }
310
- function createDiffieHellman(prime_length: number, generator?: number | Binary): DiffieHellman;
311
- function createDiffieHellman(prime: Binary): DiffieHellman;
317
+ function createDiffieHellman(prime_length: number, generator?: number | NodeJS.ArrayBufferView): DiffieHellman;
318
+ function createDiffieHellman(prime: NodeJS.ArrayBufferView): DiffieHellman;
312
319
  function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding): DiffieHellman;
313
- function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | Binary): DiffieHellman;
320
+ function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: number | NodeJS.ArrayBufferView): DiffieHellman;
314
321
  function createDiffieHellman(prime: string, prime_encoding: HexBase64Latin1Encoding, generator: string, generator_encoding: HexBase64Latin1Encoding): DiffieHellman;
315
322
  class DiffieHellman {
316
323
  private constructor();
317
324
  generateKeys(): Buffer;
318
325
  generateKeys(encoding: HexBase64Latin1Encoding): string;
319
- computeSecret(other_public_key: Binary): Buffer;
326
+ computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
320
327
  computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
321
- computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
328
+ computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
322
329
  computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
323
330
  getPrime(): Buffer;
324
331
  getPrime(encoding: HexBase64Latin1Encoding): string;
@@ -328,9 +335,9 @@ declare module "crypto" {
328
335
  getPublicKey(encoding: HexBase64Latin1Encoding): string;
329
336
  getPrivateKey(): Buffer;
330
337
  getPrivateKey(encoding: HexBase64Latin1Encoding): string;
331
- setPublicKey(public_key: Binary): void;
338
+ setPublicKey(public_key: NodeJS.ArrayBufferView): void;
332
339
  setPublicKey(public_key: string, encoding: string): void;
333
- setPrivateKey(private_key: Binary): void;
340
+ setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
334
341
  setPrivateKey(private_key: string, encoding: string): void;
335
342
  verifyError: number;
336
343
  }
@@ -350,10 +357,10 @@ declare module "crypto" {
350
357
  function pseudoRandomBytes(size: number): Buffer;
351
358
  function pseudoRandomBytes(size: number, callback: (err: Error | null, buf: Buffer) => void): void;
352
359
 
353
- function randomFillSync<T extends Binary>(buffer: T, offset?: number, size?: number): T;
354
- function randomFill<T extends Binary>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
355
- function randomFill<T extends Binary>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
356
- function randomFill<T extends Binary>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
360
+ function randomFillSync<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number, size?: number): T;
361
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
362
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
363
+ function randomFill<T extends NodeJS.ArrayBufferView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
357
364
 
358
365
  interface ScryptOptions {
359
366
  N?: number;
@@ -382,12 +389,15 @@ declare module "crypto" {
382
389
  interface RsaPrivateKey {
383
390
  key: KeyLike;
384
391
  passphrase?: string;
392
+ /**
393
+ * @default 'sha1'
394
+ */
395
+ oaepHash?: string;
396
+ oaepLabel?: NodeJS.TypedArray;
385
397
  padding?: number;
386
398
  }
387
- function publicEncrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
388
- function privateDecrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
389
- function privateEncrypt(private_key: RsaPrivateKey | KeyLike, buffer: Binary): Buffer;
390
- function publicDecrypt(public_key: RsaPublicKey | KeyLike, buffer: Binary): Buffer;
399
+ function publicEncrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
400
+ function publicDecrypt(key: RsaPublicKey | RsaPrivateKey | KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
391
401
  function getCiphers(): string[];
392
402
  function getCurves(): string[];
393
403
  function getHashes(): string[];
@@ -402,19 +412,19 @@ declare module "crypto" {
402
412
  ): Buffer | string;
403
413
  generateKeys(): Buffer;
404
414
  generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
405
- computeSecret(other_public_key: Binary): Buffer;
415
+ computeSecret(other_public_key: NodeJS.ArrayBufferView): Buffer;
406
416
  computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding): Buffer;
407
- computeSecret(other_public_key: Binary, output_encoding: HexBase64Latin1Encoding): string;
417
+ computeSecret(other_public_key: NodeJS.ArrayBufferView, output_encoding: HexBase64Latin1Encoding): string;
408
418
  computeSecret(other_public_key: string, input_encoding: HexBase64Latin1Encoding, output_encoding: HexBase64Latin1Encoding): string;
409
419
  getPrivateKey(): Buffer;
410
420
  getPrivateKey(encoding: HexBase64Latin1Encoding): string;
411
421
  getPublicKey(): Buffer;
412
422
  getPublicKey(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
413
- setPrivateKey(private_key: Binary): void;
423
+ setPrivateKey(private_key: NodeJS.ArrayBufferView): void;
414
424
  setPrivateKey(private_key: string, encoding: HexBase64Latin1Encoding): void;
415
425
  }
416
426
  function createECDH(curve_name: string): ECDH;
417
- function timingSafeEqual(a: Binary, b: Binary): boolean;
427
+ function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
418
428
  /** @deprecated since v10.0.0 */
419
429
  const DEFAULT_ENCODING: string;
420
430
 
@@ -585,7 +595,7 @@ declare module "crypto" {
585
595
  * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
586
596
  * passed to [`crypto.createPrivateKey()`][].
587
597
  */
588
- function sign(algorithm: string | null | undefined, data: Binary, key: KeyLike | SignPrivateKeyInput): Buffer;
598
+ function sign(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | SignPrivateKeyInput): Buffer;
589
599
 
590
600
  interface VerifyKeyWithOptions extends KeyObject, SigningOptions {
591
601
  }
@@ -598,5 +608,5 @@ declare module "crypto" {
598
608
  * If `key` is not a [`KeyObject`][], this function behaves as if `key` had been
599
609
  * passed to [`crypto.createPublicKey()`][].
600
610
  */
601
- function verify(algorithm: string | null | undefined, data: Binary, key: KeyLike | VerifyKeyWithOptions, signature: Binary): Buffer;
611
+ function verify(algorithm: string | null | undefined, data: NodeJS.ArrayBufferView, key: KeyLike | VerifyKeyWithOptions, signature: NodeJS.ArrayBufferView): Buffer;
602
612
  }
node/events.d.ts CHANGED
@@ -1,8 +1,17 @@
1
1
  declare module "events" {
2
2
  class internal extends NodeJS.EventEmitter { }
3
3
 
4
+ interface NodeEventTarget {
5
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
6
+ }
7
+
8
+ interface DOMEventTarget {
9
+ addEventListener(event: string, listener: (...args: any[]) => void, opts?: { once: boolean }): any;
10
+ }
11
+
4
12
  namespace internal {
5
- function once(emitter: EventEmitter, event: string | symbol): Promise<any[]>;
13
+ function once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>;
14
+ function once(emitter: DOMEventTarget, event: string): Promise<any[]>;
6
15
  class EventEmitter extends internal {
7
16
  /** @deprecated since v4.0.0 */
8
17
  static listenerCount(emitter: EventEmitter, event: string | symbol): number;
node/fs.d.ts CHANGED
@@ -8,8 +8,9 @@ declare module "fs" {
8
8
  */
9
9
  type PathLike = string | Buffer | URL;
10
10
 
11
- type BinaryData = DataView | NodeJS.TypedArray;
12
- class Stats {
11
+ type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
12
+
13
+ interface StatsBase<T> {
13
14
  isFile(): boolean;
14
15
  isDirectory(): boolean;
15
16
  isBlockDevice(): boolean;
@@ -17,6 +18,7 @@ declare module "fs" {
17
18
  isSymbolicLink(): boolean;
18
19
  isFIFO(): boolean;
19
20
  isSocket(): boolean;
21
+
20
22
  dev: number;
21
23
  ino: number;
22
24
  mode: number;
@@ -37,6 +39,12 @@ declare module "fs" {
37
39
  birthtime: Date;
38
40
  }
39
41
 
42
+ interface Stats extends StatsBase<number> {
43
+ }
44
+
45
+ class Stats {
46
+ }
47
+
40
48
  class Dirent {
41
49
  isFile(): boolean;
42
50
  isDirectory(): boolean;
@@ -146,7 +154,7 @@ declare module "fs" {
146
154
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
147
155
  * URL support is _experimental_.
148
156
  */
149
- function rename(oldPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
157
+ function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
150
158
 
151
159
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
152
160
  namespace rename {
@@ -174,14 +182,14 @@ declare module "fs" {
174
182
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
175
183
  * @param len If not specified, defaults to `0`.
176
184
  */
177
- function truncate(path: PathLike, len: number | undefined | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
185
+ function truncate(path: PathLike, len: number | undefined | null, callback: NoParamCallback): void;
178
186
 
179
187
  /**
180
188
  * Asynchronous truncate(2) - Truncate a file to a specified length.
181
189
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
182
190
  * URL support is _experimental_.
183
191
  */
184
- function truncate(path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
192
+ function truncate(path: PathLike, callback: NoParamCallback): void;
185
193
 
186
194
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
187
195
  namespace truncate {
@@ -205,13 +213,13 @@ declare module "fs" {
205
213
  * @param fd A file descriptor.
206
214
  * @param len If not specified, defaults to `0`.
207
215
  */
208
- function ftruncate(fd: number, len: number | undefined | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
216
+ function ftruncate(fd: number, len: number | undefined | null, callback: NoParamCallback): void;
209
217
 
210
218
  /**
211
219
  * Asynchronous ftruncate(2) - Truncate a file to a specified length.
212
220
  * @param fd A file descriptor.
213
221
  */
214
- function ftruncate(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
222
+ function ftruncate(fd: number, callback: NoParamCallback): void;
215
223
 
216
224
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
217
225
  namespace ftruncate {
@@ -234,7 +242,7 @@ declare module "fs" {
234
242
  * Asynchronous chown(2) - Change ownership of a file.
235
243
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
236
244
  */
237
- function chown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
245
+ function chown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
238
246
 
239
247
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
240
248
  namespace chown {
@@ -255,7 +263,7 @@ declare module "fs" {
255
263
  * Asynchronous fchown(2) - Change ownership of a file.
256
264
  * @param fd A file descriptor.
257
265
  */
258
- function fchown(fd: number, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
266
+ function fchown(fd: number, uid: number, gid: number, callback: NoParamCallback): void;
259
267
 
260
268
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
261
269
  namespace fchown {
@@ -276,7 +284,7 @@ declare module "fs" {
276
284
  * Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.
277
285
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
278
286
  */
279
- function lchown(path: PathLike, uid: number, gid: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
287
+ function lchown(path: PathLike, uid: number, gid: number, callback: NoParamCallback): void;
280
288
 
281
289
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
282
290
  namespace lchown {
@@ -298,7 +306,7 @@ declare module "fs" {
298
306
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
299
307
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
300
308
  */
301
- function chmod(path: PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException | null) => void): void;
309
+ function chmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
302
310
 
303
311
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
304
312
  namespace chmod {
@@ -322,7 +330,7 @@ declare module "fs" {
322
330
  * @param fd A file descriptor.
323
331
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
324
332
  */
325
- function fchmod(fd: number, mode: string | number, callback: (err: NodeJS.ErrnoException | null) => void): void;
333
+ function fchmod(fd: number, mode: string | number, callback: NoParamCallback): void;
326
334
 
327
335
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
328
336
  namespace fchmod {
@@ -346,7 +354,7 @@ declare module "fs" {
346
354
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
347
355
  * @param mode A file mode. If a string is passed, it is parsed as an octal integer.
348
356
  */
349
- function lchmod(path: PathLike, mode: string | number, callback: (err: NodeJS.ErrnoException | null) => void): void;
357
+ function lchmod(path: PathLike, mode: string | number, callback: NoParamCallback): void;
350
358
 
351
359
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
352
360
  namespace lchmod {
@@ -433,7 +441,7 @@ declare module "fs" {
433
441
  * @param existingPath A path to a file. If a URL is provided, it must use the `file:` protocol.
434
442
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
435
443
  */
436
- function link(existingPath: PathLike, newPath: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
444
+ function link(existingPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
437
445
 
438
446
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
439
447
  namespace link {
@@ -459,14 +467,14 @@ declare module "fs" {
459
467
  * @param type May be set to `'dir'`, `'file'`, or `'junction'` (default is `'file'`) and is only available on Windows (ignored on other platforms).
460
468
  * When using `'junction'`, the `target` argument will automatically be normalized to an absolute path.
461
469
  */
462
- function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
470
+ function symlink(target: PathLike, path: PathLike, type: symlink.Type | undefined | null, callback: NoParamCallback): void;
463
471
 
464
472
  /**
465
473
  * Asynchronous symlink(2) - Create a new symbolic link to an existing file.
466
474
  * @param target A path to an existing file. If a URL is provided, it must use the `file:` protocol.
467
475
  * @param path A path to the new symlink. If a URL is provided, it must use the `file:` protocol.
468
476
  */
469
- function symlink(target: PathLike, path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
477
+ function symlink(target: PathLike, path: PathLike, callback: NoParamCallback): void;
470
478
 
471
479
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
472
480
  namespace symlink {
@@ -662,7 +670,7 @@ declare module "fs" {
662
670
  * Asynchronous unlink(2) - delete a name and possibly the file it refers to.
663
671
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
664
672
  */
665
- function unlink(path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
673
+ function unlink(path: PathLike, callback: NoParamCallback): void;
666
674
 
667
675
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
668
676
  namespace unlink {
@@ -679,11 +687,42 @@ declare module "fs" {
679
687
  */
680
688
  function unlinkSync(path: PathLike): void;
681
689
 
690
+ interface RmDirOptions {
691
+ /**
692
+ * If `true`, perform a recursive directory removal. In
693
+ * recursive mode, errors are not reported if `path` does not exist, and
694
+ * operations are retried on failure.
695
+ * @experimental
696
+ * @default false
697
+ */
698
+ recursive?: boolean;
699
+ }
700
+
701
+ interface RmDirAsyncOptions extends RmDirOptions {
702
+ /**
703
+ * If an `EMFILE` error is encountered, Node.js will
704
+ * retry the operation with a linear backoff of 1ms longer on each try until the
705
+ * timeout duration passes this limit. This option is ignored if the `recursive`
706
+ * option is not `true`.
707
+ * @default 1000
708
+ */
709
+ emfileWait?: number;
710
+ /**
711
+ * If an `EBUSY`, `ENOTEMPTY`, or `EPERM` error is
712
+ * encountered, Node.js will retry the operation with a linear backoff wait of
713
+ * 100ms longer on each try. This option represents the number of retries. This
714
+ * option is ignored if the `recursive` option is not `true`.
715
+ * @default 3
716
+ */
717
+ maxBusyTries?: number;
718
+ }
719
+
682
720
  /**
683
721
  * Asynchronous rmdir(2) - delete a directory.
684
722
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
685
723
  */
686
- function rmdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
724
+ function rmdir(path: PathLike, callback: NoParamCallback): void;
725
+ function rmdir(path: PathLike, options: RmDirAsyncOptions, callback: NoParamCallback): void;
687
726
 
688
727
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
689
728
  namespace rmdir {
@@ -691,14 +730,14 @@ declare module "fs" {
691
730
  * Asynchronous rmdir(2) - delete a directory.
692
731
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
693
732
  */
694
- function __promisify__(path: PathLike): Promise<void>;
733
+ function __promisify__(path: PathLike, options?: RmDirAsyncOptions): Promise<void>;
695
734
  }
696
735
 
697
736
  /**
698
737
  * Synchronous rmdir(2) - delete a directory.
699
738
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
700
739
  */
701
- function rmdirSync(path: PathLike): void;
740
+ function rmdirSync(path: PathLike, options?: RmDirOptions): void;
702
741
 
703
742
  export interface MakeDirectoryOptions {
704
743
  /**
@@ -719,13 +758,13 @@ declare module "fs" {
719
758
  * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
720
759
  * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
721
760
  */
722
- function mkdir(path: PathLike, options: number | string | MakeDirectoryOptions | undefined | null, callback: (err: NodeJS.ErrnoException | null) => void): void;
761
+ function mkdir(path: PathLike, options: number | string | MakeDirectoryOptions | undefined | null, callback: NoParamCallback): void;
723
762
 
724
763
  /**
725
764
  * Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
726
765
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
727
766
  */
728
- function mkdir(path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
767
+ function mkdir(path: PathLike, callback: NoParamCallback): void;
729
768
 
730
769
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
731
770
  namespace mkdir {
@@ -923,7 +962,7 @@ declare module "fs" {
923
962
  * Asynchronous close(2) - close a file descriptor.
924
963
  * @param fd A file descriptor.
925
964
  */
926
- function close(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
965
+ function close(fd: number, callback: NoParamCallback): void;
927
966
 
928
967
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
929
968
  namespace close {
@@ -976,7 +1015,7 @@ declare module "fs" {
976
1015
  * @param atime The last access time. If a string is provided, it will be coerced to number.
977
1016
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
978
1017
  */
979
- function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException | null) => void): void;
1018
+ function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
980
1019
 
981
1020
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
982
1021
  namespace utimes {
@@ -1003,7 +1042,7 @@ declare module "fs" {
1003
1042
  * @param atime The last access time. If a string is provided, it will be coerced to number.
1004
1043
  * @param mtime The last modified time. If a string is provided, it will be coerced to number.
1005
1044
  */
1006
- function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: (err: NodeJS.ErrnoException | null) => void): void;
1045
+ function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date, callback: NoParamCallback): void;
1007
1046
 
1008
1047
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1009
1048
  namespace futimes {
@@ -1028,7 +1067,7 @@ declare module "fs" {
1028
1067
  * Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.
1029
1068
  * @param fd A file descriptor.
1030
1069
  */
1031
- function fsync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
1070
+ function fsync(fd: number, callback: NoParamCallback): void;
1032
1071
 
1033
1072
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1034
1073
  namespace fsync {
@@ -1052,7 +1091,7 @@ declare module "fs" {
1052
1091
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1053
1092
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1054
1093
  */
1055
- function write<TBuffer extends BinaryData>(
1094
+ function write<TBuffer extends NodeJS.ArrayBufferView>(
1056
1095
  fd: number,
1057
1096
  buffer: TBuffer,
1058
1097
  offset: number | undefined | null,
@@ -1067,7 +1106,7 @@ declare module "fs" {
1067
1106
  * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
1068
1107
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1069
1108
  */
1070
- function write<TBuffer extends BinaryData>(
1109
+ function write<TBuffer extends NodeJS.ArrayBufferView>(
1071
1110
  fd: number,
1072
1111
  buffer: TBuffer,
1073
1112
  offset: number | undefined | null,
@@ -1080,7 +1119,7 @@ declare module "fs" {
1080
1119
  * @param fd A file descriptor.
1081
1120
  * @param offset The part of the buffer to be written. If not supplied, defaults to `0`.
1082
1121
  */
1083
- function write<TBuffer extends BinaryData>(
1122
+ function write<TBuffer extends NodeJS.ArrayBufferView>(
1084
1123
  fd: number,
1085
1124
  buffer: TBuffer,
1086
1125
  offset: number | undefined | null,
@@ -1091,7 +1130,7 @@ declare module "fs" {
1091
1130
  * Asynchronously writes `buffer` to the file referenced by the supplied file descriptor.
1092
1131
  * @param fd A file descriptor.
1093
1132
  */
1094
- function write<TBuffer extends BinaryData>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
1133
+ function write<TBuffer extends NodeJS.ArrayBufferView>(fd: number, buffer: TBuffer, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: TBuffer) => void): void;
1095
1134
 
1096
1135
  /**
1097
1136
  * Asynchronously writes `string` to the file referenced by the supplied file descriptor.
@@ -1132,7 +1171,7 @@ declare module "fs" {
1132
1171
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1133
1172
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1134
1173
  */
1135
- function __promisify__<TBuffer extends BinaryData>(
1174
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
1136
1175
  fd: number,
1137
1176
  buffer?: TBuffer,
1138
1177
  offset?: number,
@@ -1157,7 +1196,7 @@ declare module "fs" {
1157
1196
  * @param length The number of bytes to write. If not supplied, defaults to `buffer.length - offset`.
1158
1197
  * @param position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
1159
1198
  */
1160
- function writeSync(fd: number, buffer: BinaryData, offset?: number | null, length?: number | null, position?: number | null): number;
1199
+ function writeSync(fd: number, buffer: NodeJS.ArrayBufferView, offset?: number | null, length?: number | null, position?: number | null): number;
1161
1200
 
1162
1201
  /**
1163
1202
  * Synchronously writes `string` to the file referenced by the supplied file descriptor, returning the number of bytes written.
@@ -1176,7 +1215,7 @@ declare module "fs" {
1176
1215
  * @param length The number of bytes to read.
1177
1216
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1178
1217
  */
1179
- function read<TBuffer extends BinaryData>(
1218
+ function read<TBuffer extends NodeJS.ArrayBufferView>(
1180
1219
  fd: number,
1181
1220
  buffer: TBuffer,
1182
1221
  offset: number,
@@ -1194,7 +1233,13 @@ declare module "fs" {
1194
1233
  * @param length The number of bytes to read.
1195
1234
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1196
1235
  */
1197
- function __promisify__<TBuffer extends BinaryData>(fd: number, buffer: TBuffer, offset: number, length: number, position: number | null): Promise<{ bytesRead: number, buffer: TBuffer }>;
1236
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
1237
+ fd: number,
1238
+ buffer: TBuffer,
1239
+ offset: number,
1240
+ length: number,
1241
+ position: number | null
1242
+ ): Promise<{ bytesRead: number, buffer: TBuffer }>;
1198
1243
  }
1199
1244
 
1200
1245
  /**
@@ -1205,7 +1250,7 @@ declare module "fs" {
1205
1250
  * @param length The number of bytes to read.
1206
1251
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1207
1252
  */
1208
- function readSync(fd: number, buffer: BinaryData, offset: number, length: number, position: number | null): number;
1253
+ function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
1209
1254
 
1210
1255
  /**
1211
1256
  * Asynchronously reads the entire contents of a file.
@@ -1322,7 +1367,7 @@ declare module "fs" {
1322
1367
  * If `mode` is a string, it is parsed as an octal integer.
1323
1368
  * If `flag` is not supplied, the default of `'w'` is used.
1324
1369
  */
1325
- function writeFile(path: PathLike | number, data: any, options: WriteFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
1370
+ function writeFile(path: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
1326
1371
 
1327
1372
  /**
1328
1373
  * Asynchronously writes data to a file, replacing the file if it already exists.
@@ -1331,7 +1376,7 @@ declare module "fs" {
1331
1376
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1332
1377
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1333
1378
  */
1334
- function writeFile(path: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void;
1379
+ function writeFile(path: PathLike | number, data: any, callback: NoParamCallback): void;
1335
1380
 
1336
1381
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1337
1382
  namespace writeFile {
@@ -1376,7 +1421,7 @@ declare module "fs" {
1376
1421
  * If `mode` is a string, it is parsed as an octal integer.
1377
1422
  * If `flag` is not supplied, the default of `'a'` is used.
1378
1423
  */
1379
- function appendFile(file: PathLike | number, data: any, options: WriteFileOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
1424
+ function appendFile(file: PathLike | number, data: any, options: WriteFileOptions, callback: NoParamCallback): void;
1380
1425
 
1381
1426
  /**
1382
1427
  * Asynchronously append data to a file, creating the file if it does not exist.
@@ -1385,7 +1430,7 @@ declare module "fs" {
1385
1430
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1386
1431
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1387
1432
  */
1388
- function appendFile(file: PathLike | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void;
1433
+ function appendFile(file: PathLike | number, data: any, callback: NoParamCallback): void;
1389
1434
 
1390
1435
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1391
1436
  namespace appendFile {
@@ -1663,6 +1708,13 @@ declare module "fs" {
1663
1708
 
1664
1709
  /** Constant for fs.Stats mode property for determining access permissions for a file. File mode indicating executable by others. */
1665
1710
  const S_IXOTH: number;
1711
+
1712
+ /**
1713
+ * When set, a memory file mapping is used to access the file. This flag
1714
+ * is available on Windows operating systems only. On other operating systems,
1715
+ * this flag is ignored.
1716
+ */
1717
+ const UV_FS_O_FILEMAP: number;
1666
1718
  }
1667
1719
 
1668
1720
  /**
@@ -1670,14 +1722,14 @@ declare module "fs" {
1670
1722
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1671
1723
  * URL support is _experimental_.
1672
1724
  */
1673
- function access(path: PathLike, mode: number | undefined, callback: (err: NodeJS.ErrnoException | null) => void): void;
1725
+ function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
1674
1726
 
1675
1727
  /**
1676
1728
  * Asynchronously tests a user's permissions for the file specified by path.
1677
1729
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1678
1730
  * URL support is _experimental_.
1679
1731
  */
1680
- function access(path: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
1732
+ function access(path: PathLike, callback: NoParamCallback): void;
1681
1733
 
1682
1734
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1683
1735
  namespace access {
@@ -1707,6 +1759,10 @@ declare module "fs" {
1707
1759
  fd?: number;
1708
1760
  mode?: number;
1709
1761
  autoClose?: boolean;
1762
+ /**
1763
+ * @default false
1764
+ */
1765
+ emitClose?: boolean;
1710
1766
  start?: number;
1711
1767
  end?: number;
1712
1768
  highWaterMark?: number;
@@ -1731,7 +1787,7 @@ declare module "fs" {
1731
1787
  * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
1732
1788
  * @param fd A file descriptor.
1733
1789
  */
1734
- function fdatasync(fd: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
1790
+ function fdatasync(fd: number, callback: NoParamCallback): void;
1735
1791
 
1736
1792
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1737
1793
  namespace fdatasync {
@@ -1757,7 +1813,7 @@ declare module "fs" {
1757
1813
  * @param src A path to the source file.
1758
1814
  * @param dest A path to the destination file.
1759
1815
  */
1760
- function copyFile(src: PathLike, dest: PathLike, callback: (err: NodeJS.ErrnoException | null) => void): void;
1816
+ function copyFile(src: PathLike, dest: PathLike, callback: NoParamCallback): void;
1761
1817
  /**
1762
1818
  * Asynchronously copies src to dest. By default, dest is overwritten if it already exists.
1763
1819
  * No arguments other than a possible exception are given to the callback function.
@@ -1768,7 +1824,7 @@ declare module "fs" {
1768
1824
  * @param dest A path to the destination file.
1769
1825
  * @param flags An integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.
1770
1826
  */
1771
- function copyFile(src: PathLike, dest: PathLike, flags: number, callback: (err: NodeJS.ErrnoException | null) => void): void;
1827
+ function copyFile(src: PathLike, dest: PathLike, flags: number, callback: NoParamCallback): void;
1772
1828
 
1773
1829
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1774
1830
  namespace copyFile {
@@ -1799,6 +1855,39 @@ declare module "fs" {
1799
1855
  */
1800
1856
  function copyFileSync(src: PathLike, dest: PathLike, flags?: number): void;
1801
1857
 
1858
+ /**
1859
+ * Write an array of ArrayBufferViews to the file specified by fd using writev().
1860
+ * position is the offset from the beginning of the file where this data should be written.
1861
+ * It is unsafe to use fs.writev() multiple times on the same file without waiting for the callback. For this scenario, use fs.createWriteStream().
1862
+ * On Linux, positional writes don't work when the file is opened in append mode.
1863
+ * The kernel ignores the position argument and always appends the data to the end of the file.
1864
+ */
1865
+ function writev(
1866
+ fd: number,
1867
+ buffers: NodeJS.ArrayBufferView[],
1868
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
1869
+ ): void;
1870
+ function writev(
1871
+ fd: number,
1872
+ buffers: NodeJS.ArrayBufferView[],
1873
+ position: number,
1874
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void
1875
+ ): void;
1876
+
1877
+ interface WriteVResult {
1878
+ bytesWritten: number;
1879
+ buffers: NodeJS.ArrayBufferView[];
1880
+ }
1881
+
1882
+ namespace writev {
1883
+ function __promisify__(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
1884
+ }
1885
+
1886
+ /**
1887
+ * See `writev`.
1888
+ */
1889
+ function writevSync(fd: number, buffers: NodeJS.ArrayBufferView[], position?: number): number;
1890
+
1802
1891
  namespace promises {
1803
1892
  interface FileHandle {
1804
1893
  /**
@@ -1925,6 +2014,11 @@ declare module "fs" {
1925
2014
  */
1926
2015
  writeFile(data: any, options?: { encoding?: string | null, mode?: string | number, flag?: string | number } | string | null): Promise<void>;
1927
2016
 
2017
+ /**
2018
+ * See `fs.writev` promisified version.
2019
+ */
2020
+ writev(buffers: NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
2021
+
1928
2022
  /**
1929
2023
  * Asynchronous close(2) - close a `FileHandle`.
1930
2024
  */
node/globals.d.ts CHANGED
@@ -341,7 +341,7 @@ declare class Buffer extends Uint8Array {
341
341
  * @param encoding encoding used to evaluate (defaults to 'utf8')
342
342
  */
343
343
  static byteLength(
344
- string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer,
344
+ string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
345
345
  encoding?: BufferEncoding
346
346
  ): number;
347
347
  /**
@@ -651,9 +651,7 @@ declare namespace NodeJS {
651
651
 
652
652
  interface ReadWriteStream extends ReadableStream, WritableStream { }
653
653
 
654
- interface Events extends EventEmitter { }
655
-
656
- interface Domain extends Events {
654
+ interface Domain extends EventEmitter {
657
655
  run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
658
656
  add(emitter: EventEmitter | Timer): void;
659
657
  remove(emitter: EventEmitter | Timer): void;
@@ -737,31 +735,6 @@ declare namespace NodeJS {
737
735
  [key: string]: string | undefined;
738
736
  }
739
737
 
740
- interface WriteStream extends Socket {
741
- readonly writableFinished: boolean;
742
- readonly writableHighWaterMark: number;
743
- readonly writableLength: number;
744
- columns?: number;
745
- rows?: number;
746
- _write(chunk: any, encoding: string, callback: (err?: null | Error) => void): void;
747
- _destroy(err: Error | null, callback: (err?: null | Error) => void): void;
748
- _final(callback: (err?: null | Error) => void): void;
749
- setDefaultEncoding(encoding: string): this;
750
- cork(): void;
751
- uncork(): void;
752
- destroy(error?: Error): void;
753
- }
754
- interface ReadStream extends Socket {
755
- readonly readableHighWaterMark: number;
756
- readonly readableLength: number;
757
- isRaw?: boolean;
758
- setRawMode?(mode: boolean): void;
759
- _read(size: number): void;
760
- _destroy(err: Error | null, callback: (err?: null | Error) => void): void;
761
- push(chunk: any, encoding?: string): boolean;
762
- destroy(error?: Error): void;
763
- }
764
-
765
738
  interface HRTime {
766
739
  (time?: [number, number]): [number, number];
767
740
  }
@@ -1177,4 +1150,5 @@ declare namespace NodeJS {
1177
1150
  }
1178
1151
 
1179
1152
  type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
1153
+ type ArrayBufferView = TypedArray | DataView;
1180
1154
  }
node/http2.d.ts CHANGED
@@ -277,12 +277,12 @@ declare module "http2" {
277
277
  destroy(error?: Error, code?: number): void;
278
278
  readonly destroyed: boolean;
279
279
  readonly encrypted?: boolean;
280
- goaway(code?: number, lastStreamID?: number, opaqueData?: Buffer | DataView | NodeJS.TypedArray): void;
280
+ goaway(code?: number, lastStreamID?: number, opaqueData?: NodeJS.ArrayBufferView): void;
281
281
  readonly localSettings: Settings;
282
282
  readonly originSet?: string[];
283
283
  readonly pendingSettingsAck: boolean;
284
284
  ping(callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
285
- ping(payload: Buffer | DataView | NodeJS.TypedArray , callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
285
+ ping(payload: NodeJS.ArrayBufferView, callback: (err: Error | null, duration: number, payload: Buffer) => void): boolean;
286
286
  ref(): void;
287
287
  readonly remoteSettings: Settings;
288
288
  setTimeout(msecs: number, callback?: () => void): void;
node/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 12.7
1
+ // Type definitions for non-npm package Node.js 12.11
2
2
  // Project: http://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
@@ -67,8 +67,8 @@ interface WeakSetConstructor { }
67
67
  interface Set<T> {}
68
68
  interface Map<K, V> {}
69
69
  interface ReadonlySet<T> {}
70
- interface IteratorResult<T> { }
71
70
  interface Iterable<T> { }
71
+ interface IteratorResult<T> { }
72
72
  interface AsyncIterable<T> { }
73
73
  interface Iterator<T> {
74
74
  next(value?: any): IteratorResult<T>;
node/net.d.ts CHANGED
@@ -18,7 +18,26 @@ declare module "net" {
18
18
  writable?: boolean;
19
19
  }
20
20
 
21
- interface TcpSocketConnectOpts {
21
+ interface OnReadOpts {
22
+ buffer: Uint8Array | (() => Uint8Array);
23
+ /**
24
+ * This function is called for every chunk of incoming data.
25
+ * Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
26
+ * Return false from this function to implicitly pause() the socket.
27
+ */
28
+ callback(bytesWritten: number, buf: Uint8Array): boolean;
29
+ }
30
+
31
+ interface ConnectOpts {
32
+ /**
33
+ * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
34
+ * Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
35
+ * still be emitted as normal and methods like pause() and resume() will also behave as expected.
36
+ */
37
+ onread?: OnReadOpts;
38
+ }
39
+
40
+ interface TcpSocketConnectOpts extends ConnectOpts {
22
41
  port: number;
23
42
  host?: string;
24
43
  localAddress?: string;
@@ -28,7 +47,7 @@ declare module "net" {
28
47
  lookup?: LookupFunction;
29
48
  }
30
49
 
31
- interface IpcSocketConnectOpts {
50
+ interface IpcSocketConnectOpts extends ConnectOpts {
32
51
  path: string;
33
52
  }
34
53
 
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "12.7.10",
3
+ "version": "12.11.1",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -211,6 +211,6 @@
211
211
  },
212
212
  "scripts": {},
213
213
  "dependencies": {},
214
- "typesPublisherContentHash": "2c3f119a959d6c63e80374054379fba87089eb190ed7cecb1286d4ef85a828a9",
214
+ "typesPublisherContentHash": "9ac4a6964ec22ccb1141052fab85bf0d16247a1dfe5c2f2328c19440915c36ef",
215
215
  "typeScriptVersion": "2.0"
216
216
  }
node/process.d.ts CHANGED
@@ -1,3 +1,15 @@
1
1
  declare module "process" {
2
+ import * as tty from "tty";
3
+
4
+ global {
5
+ namespace NodeJS {
6
+ // this namespace merge is here because these are specifically used
7
+ // as the type for process.stdin, process.stdout, and process.stderr.
8
+ // they can't live in tty.d.ts because we need to disambiguate the imported name.
9
+ interface ReadStream extends tty.ReadStream {}
10
+ interface WriteStream extends tty.WriteStream {}
11
+ }
12
+ }
13
+
2
14
  export = process;
3
15
  }
node/ts3.2/fs.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ // tslint:disable-next-line:no-bad-reference
2
+ /// <reference path="../fs.d.ts" />
3
+
4
+ declare module 'fs' {
5
+ interface BigIntStats extends StatsBase<BigInt> {
6
+ }
7
+
8
+ class BigIntStats {
9
+ atimeNs: BigInt;
10
+ mtimeNs: BigInt;
11
+ ctimeNs: BigInt;
12
+ birthtimeNs: BigInt;
13
+ }
14
+
15
+ interface BigIntOptions {
16
+ bigint: true;
17
+ }
18
+
19
+ interface StatOptions {
20
+ bigint: boolean;
21
+ }
22
+
23
+ function stat(path: PathLike, options: BigIntOptions, callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void): void;
24
+ function stat(path: PathLike, options: StatOptions, callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void): void;
25
+
26
+ namespace stat {
27
+ function __promisify__(path: PathLike, options: BigIntOptions): Promise<BigIntStats>;
28
+ function __promisify__(path: PathLike, options: StatOptions): Promise<Stats | BigIntStats>;
29
+ }
30
+
31
+ function statSync(path: PathLike, options: BigIntOptions): BigIntStats;
32
+ function statSync(path: PathLike, options: StatOptions): Stats | BigIntStats;
33
+ }
node/ts3.2/index.d.ts CHANGED
@@ -16,5 +16,6 @@
16
16
  /// <reference path="../base.d.ts" />
17
17
 
18
18
  // TypeScript 3.2-specific augmentations:
19
+ /// <reference path="fs.d.ts" />
19
20
  /// <reference path="util.d.ts" />
20
21
  /// <reference path="globals.d.ts" />
node/util.d.ts CHANGED
@@ -51,7 +51,7 @@ declare module "util" {
51
51
  function isSymbol(object: any): object is symbol;
52
52
  /** @deprecated since v4.0.0 - use `value === undefined` instead. */
53
53
  function isUndefined(object: any): object is undefined;
54
- function deprecate<T extends Function>(fn: T, message: string): T;
54
+ function deprecate<T extends Function>(fn: T, message: string, code?: string): T;
55
55
  function isDeepStrictEqual(val1: any, val2: any): boolean;
56
56
 
57
57
  interface CustomPromisify<TCustom extends Function> extends Function {
@@ -153,13 +153,26 @@ declare module "util" {
153
153
  options?: { fatal?: boolean; ignoreBOM?: boolean }
154
154
  );
155
155
  decode(
156
- input?: NodeJS.TypedArray | DataView | ArrayBuffer | null,
156
+ input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
157
157
  options?: { stream?: boolean }
158
158
  ): string;
159
159
  }
160
160
 
161
+ interface EncodeIntoResult {
162
+ /**
163
+ * The read Unicode code units of input.
164
+ */
165
+
166
+ read: number;
167
+ /**
168
+ * The written UTF-8 bytes of output.
169
+ */
170
+ written: number;
171
+ }
172
+
161
173
  class TextEncoder {
162
174
  readonly encoding: string;
163
175
  encode(input?: string): Uint8Array;
176
+ encodeInto(input: string, output: Uint8Array): EncodeIntoResult;
164
177
  }
165
178
  }
node/v8.d.ts CHANGED
@@ -26,6 +26,18 @@ declare module "v8" {
26
26
  number_of_detached_contexts: number;
27
27
  }
28
28
 
29
+ interface HeapCodeStatistics {
30
+ code_and_metadata_size: number;
31
+ bytecode_and_metadata_size: number;
32
+ external_script_source_size: number;
33
+ }
34
+
35
+ /**
36
+ * Returns an integer representing a "version tag" derived from the V8 version, command line flags and detected CPU features.
37
+ * This is useful for determining whether a vm.Script cachedData buffer is compatible with this instance of V8.
38
+ */
39
+ function cachedDataVersionTag(): number;
40
+
29
41
  function getHeapStatistics(): HeapInfo;
30
42
  function getHeapSpaceStatistics(): HeapSpaceInfo[];
31
43
  function setFlagsFromString(flags: string): void;
@@ -49,4 +61,137 @@ declare module "v8" {
49
61
  * the main Node.js thread or the id of a worker thread.
50
62
  */
51
63
  function writeHeapSnapshot(fileName?: string): string;
64
+
65
+ function getHeapCodeStatistics(): HeapCodeStatistics;
66
+
67
+ /**
68
+ * @experimental
69
+ */
70
+ class Serializer {
71
+ /**
72
+ * Writes out a header, which includes the serialization format version.
73
+ */
74
+ writeHeader(): void;
75
+
76
+ /**
77
+ * Serializes a JavaScript value and adds the serialized representation to the internal buffer.
78
+ * This throws an error if value cannot be serialized.
79
+ */
80
+ writeValue(val: any): boolean;
81
+
82
+ /**
83
+ * Returns the stored internal buffer.
84
+ * This serializer should not be used once the buffer is released.
85
+ * Calling this method results in undefined behavior if a previous write has failed.
86
+ */
87
+ releaseBuffer(): Buffer;
88
+
89
+ /**
90
+ * Marks an ArrayBuffer as having its contents transferred out of band.\
91
+ * Pass the corresponding ArrayBuffer in the deserializing context to deserializer.transferArrayBuffer().
92
+ */
93
+ transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
94
+
95
+ /**
96
+ * Write a raw 32-bit unsigned integer.
97
+ */
98
+ writeUint32(value: number): void;
99
+
100
+ /**
101
+ * Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
102
+ */
103
+ writeUint64(hi: number, lo: number): void;
104
+
105
+ /**
106
+ * Write a JS number value.
107
+ */
108
+ writeDouble(value: number): void;
109
+
110
+ /**
111
+ * Write raw bytes into the serializer’s internal buffer.
112
+ * The deserializer will require a way to compute the length of the buffer.
113
+ */
114
+ writeRawBytes(buffer: NodeJS.TypedArray): void;
115
+ }
116
+
117
+ /**
118
+ * A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
119
+ * and only stores the part of their underlying `ArrayBuffers` that they are referring to.
120
+ * @experimental
121
+ */
122
+ class DefaultSerializer extends Serializer {
123
+ }
124
+
125
+ /**
126
+ * @experimental
127
+ */
128
+ class Deserializer {
129
+ constructor(data: NodeJS.TypedArray);
130
+ /**
131
+ * Reads and validates a header (including the format version).
132
+ * May, for example, reject an invalid or unsupported wire format.
133
+ * In that case, an Error is thrown.
134
+ */
135
+ readHeader(): boolean;
136
+
137
+ /**
138
+ * Deserializes a JavaScript value from the buffer and returns it.
139
+ */
140
+ readValue(): any;
141
+
142
+ /**
143
+ * Marks an ArrayBuffer as having its contents transferred out of band.
144
+ * Pass the corresponding `ArrayBuffer` in the serializing context to serializer.transferArrayBuffer()
145
+ * (or return the id from serializer._getSharedArrayBufferId() in the case of SharedArrayBuffers).
146
+ */
147
+ transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
148
+
149
+ /**
150
+ * Reads the underlying wire format version.
151
+ * Likely mostly to be useful to legacy code reading old wire format versions.
152
+ * May not be called before .readHeader().
153
+ */
154
+ getWireFormatVersion(): number;
155
+
156
+ /**
157
+ * Read a raw 32-bit unsigned integer and return it.
158
+ */
159
+ readUint32(): number;
160
+
161
+ /**
162
+ * Read a raw 64-bit unsigned integer and return it as an array [hi, lo] with two 32-bit unsigned integer entries.
163
+ */
164
+ readUint64(): [number, number];
165
+
166
+ /**
167
+ * Read a JS number value.
168
+ */
169
+ readDouble(): number;
170
+
171
+ /**
172
+ * Read raw bytes from the deserializer’s internal buffer.
173
+ * The length parameter must correspond to the length of the buffer that was passed to serializer.writeRawBytes().
174
+ */
175
+ readRawBytes(length: number): Buffer;
176
+ }
177
+
178
+ /**
179
+ * A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
180
+ * and only stores the part of their underlying `ArrayBuffers` that they are referring to.
181
+ * @experimental
182
+ */
183
+ class DefaultDeserializer extends Deserializer {
184
+ }
185
+
186
+ /**
187
+ * Uses a `DefaultSerializer` to serialize value into a buffer.
188
+ * @experimental
189
+ */
190
+ function serialize(value: any): Buffer;
191
+
192
+ /**
193
+ * Uses a `DefaultDeserializer` with default options to read a JS value from a buffer.
194
+ * @experimental
195
+ */
196
+ function deserialize(data: NodeJS.TypedArray): any;
52
197
  }
node/vm.d.ts CHANGED
@@ -26,8 +26,23 @@ declare module "vm" {
26
26
  produceCachedData?: boolean;
27
27
  }
28
28
  interface RunningScriptOptions extends BaseOptions {
29
+ /**
30
+ * When `true`, if an `Error` occurs while compiling the `code`, the line of code causing the error is attached to the stack trace.
31
+ * Default: `true`.
32
+ */
29
33
  displayErrors?: boolean;
34
+ /**
35
+ * Specifies the number of milliseconds to execute code before terminating execution.
36
+ * If execution is terminated, an `Error` will be thrown. This value must be a strictly positive integer.
37
+ */
30
38
  timeout?: number;
39
+ /**
40
+ * If `true`, the execution will be terminated when `SIGINT` (Ctrl+C) is received.
41
+ * Existing handlers for the event that have been attached via `process.on('SIGINT')` will be disabled during script execution, but will continue to work after that.
42
+ * If execution is terminated, an `Error` will be thrown.
43
+ * Default: `false`.
44
+ */
45
+ breakOnSigint?: boolean;
31
46
  }
32
47
  interface CompileFunctionOptions extends BaseOptions {
33
48
  /**
node/zlib.d.ts CHANGED
@@ -18,7 +18,7 @@ declare module "zlib" {
18
18
  level?: number; // compression only
19
19
  memLevel?: number; // compression only
20
20
  strategy?: number; // compression only
21
- dictionary?: NodeJS.TypedArray | DataView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
21
+ dictionary?: NodeJS.ArrayBufferView | ArrayBuffer; // deflate/inflate only, empty dictionary by default
22
22
  }
23
23
 
24
24
  interface BrotliOptions {
@@ -79,7 +79,7 @@ declare module "zlib" {
79
79
  function createInflateRaw(options?: ZlibOptions): InflateRaw;
80
80
  function createUnzip(options?: ZlibOptions): Unzip;
81
81
 
82
- type InputType = string | DataView | ArrayBuffer | NodeJS.TypedArray;
82
+ type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
83
83
 
84
84
  type CompressCallback = (error: Error | null, result: Buffer) => void;
85
85