@types/node 18.16.5 → 20.1.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.
Files changed (111) hide show
  1. node v18.16/README.md → node/README.md +2 -2
  2. node v18.16/ts4.8/assert.d.ts → node/assert.d.ts +71 -75
  3. node v18.16/async_hooks.d.ts → node/async_hooks.d.ts +62 -42
  4. node v18.16/buffer.d.ts → node/buffer.d.ts +127 -99
  5. node v18.16/child_process.d.ts → node/child_process.d.ts +50 -54
  6. node v18.16/ts4.8/cluster.d.ts → node/cluster.d.ts +12 -12
  7. node v18.16/ts4.8/console.d.ts → node/console.d.ts +5 -5
  8. node v18.16/crypto.d.ts → node/crypto.d.ts +209 -220
  9. node v18.16/ts4.8/dgram.d.ts → node/dgram.d.ts +15 -15
  10. node v18.16/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +25 -26
  11. node v18.16/dns/promises.d.ts → node/dns/promises.d.ts +6 -6
  12. node v18.16/ts4.8/dns.d.ts → node/dns.d.ts +24 -16
  13. node v18.16/domain.d.ts → node/domain.d.ts +4 -4
  14. node v18.16/events.d.ts → node/events.d.ts +60 -60
  15. node v18.16/fs/promises.d.ts → node/fs/promises.d.ts +78 -48
  16. node v18.16/fs.d.ts → node/fs.d.ts +117 -81
  17. node v18.16/http.d.ts → node/http.d.ts +155 -145
  18. node v18.16/ts4.8/http2.d.ts → node/http2.d.ts +42 -46
  19. node v18.16/https.d.ts → node/https.d.ts +52 -153
  20. node v18.16/index.d.ts → node/index.d.ts +1 -1
  21. node v18.16/ts4.8/inspector.d.ts → node/inspector.d.ts +10 -3
  22. node v18.16/ts4.8/module.d.ts → node/module.d.ts +5 -4
  23. node v18.16/ts4.8/net.d.ts → node/net.d.ts +24 -21
  24. node v18.16/ts4.8/os.d.ts → node/os.d.ts +22 -18
  25. node v18.16/package.json → node/package.json +2 -2
  26. node v18.16/ts4.8/path.d.ts → node/path.d.ts +4 -4
  27. node v18.16/perf_hooks.d.ts → node/perf_hooks.d.ts +28 -15
  28. node v18.16/process.d.ts → node/process.d.ts +43 -46
  29. node v18.16/ts4.8/punycode.d.ts → node/punycode.d.ts +1 -1
  30. node v18.16/ts4.8/querystring.d.ts → node/querystring.d.ts +5 -5
  31. node v18.16/readline/promises.d.ts → node/readline/promises.d.ts +6 -4
  32. node v18.16/readline.d.ts → node/readline.d.ts +15 -15
  33. node v18.16/repl.d.ts → node/repl.d.ts +9 -9
  34. node v18.16/stream/consumers.d.ts → node/stream/consumers.d.ts +1 -1
  35. node v18.16/stream.d.ts → node/stream.d.ts +88 -136
  36. node v18.16/ts4.8/string_decoder.d.ts → node/string_decoder.d.ts +6 -6
  37. node v18.16/ts4.8/test.d.ts → node/test.d.ts +423 -186
  38. node v18.16/timers/promises.d.ts → node/timers/promises.d.ts +3 -3
  39. node v18.16/timers.d.ts → node/timers.d.ts +2 -2
  40. node v18.16/ts4.8/tls.d.ts → node/tls.d.ts +24 -16
  41. node v18.16/ts4.8/trace_events.d.ts → node/trace_events.d.ts +20 -9
  42. node v18.16/assert.d.ts → node/ts4.8/assert.d.ts +71 -75
  43. node v18.16/ts4.8/async_hooks.d.ts → node/ts4.8/async_hooks.d.ts +62 -42
  44. node v18.16/ts4.8/buffer.d.ts → node/ts4.8/buffer.d.ts +127 -99
  45. node v18.16/ts4.8/child_process.d.ts → node/ts4.8/child_process.d.ts +50 -54
  46. node v18.16/cluster.d.ts → node/ts4.8/cluster.d.ts +12 -12
  47. node v18.16/console.d.ts → node/ts4.8/console.d.ts +5 -5
  48. node v18.16/ts4.8/crypto.d.ts → node/ts4.8/crypto.d.ts +209 -220
  49. node v18.16/dgram.d.ts → node/ts4.8/dgram.d.ts +15 -15
  50. node v18.16/ts4.8/diagnostics_channel.d.ts → node/ts4.8/diagnostics_channel.d.ts +25 -26
  51. node v18.16/ts4.8/dns/promises.d.ts → node/ts4.8/dns/promises.d.ts +6 -6
  52. node v18.16/dns.d.ts → node/ts4.8/dns.d.ts +24 -16
  53. node v18.16/ts4.8/domain.d.ts → node/ts4.8/domain.d.ts +4 -4
  54. node v18.16/ts4.8/events.d.ts → node/ts4.8/events.d.ts +60 -60
  55. node v18.16/ts4.8/fs/promises.d.ts → node/ts4.8/fs/promises.d.ts +96 -45
  56. node v18.16/ts4.8/fs.d.ts → node/ts4.8/fs.d.ts +203 -67
  57. node v18.16/ts4.8/globals.d.ts → node/ts4.8/globals.d.ts +29 -28
  58. node v18.16/ts4.8/http.d.ts → node/ts4.8/http.d.ts +198 -126
  59. node v18.16/http2.d.ts → node/ts4.8/http2.d.ts +42 -46
  60. node v18.16/ts4.8/https.d.ts → node/ts4.8/https.d.ts +52 -153
  61. node v18.16/inspector.d.ts → node/ts4.8/inspector.d.ts +10 -3
  62. node v18.16/module.d.ts → node/ts4.8/module.d.ts +5 -4
  63. node v18.16/net.d.ts → node/ts4.8/net.d.ts +21 -18
  64. node v18.16/os.d.ts → node/ts4.8/os.d.ts +22 -18
  65. node v18.16/path.d.ts → node/ts4.8/path.d.ts +4 -4
  66. node v18.16/ts4.8/perf_hooks.d.ts → node/ts4.8/perf_hooks.d.ts +28 -15
  67. node v18.16/ts4.8/process.d.ts → node/ts4.8/process.d.ts +43 -46
  68. node v18.16/punycode.d.ts → node/ts4.8/punycode.d.ts +1 -1
  69. node v18.16/querystring.d.ts → node/ts4.8/querystring.d.ts +5 -5
  70. node v18.16/ts4.8/readline/promises.d.ts → node/ts4.8/readline/promises.d.ts +6 -4
  71. node v18.16/ts4.8/readline.d.ts → node/ts4.8/readline.d.ts +15 -15
  72. node v18.16/ts4.8/repl.d.ts → node/ts4.8/repl.d.ts +9 -9
  73. node v18.16/ts4.8/stream/consumers.d.ts → node/ts4.8/stream/consumers.d.ts +1 -1
  74. node v18.16/ts4.8/stream.d.ts → node/ts4.8/stream.d.ts +91 -139
  75. node v18.16/string_decoder.d.ts → node/ts4.8/string_decoder.d.ts +6 -6
  76. node v18.16/test.d.ts → node/ts4.8/test.d.ts +423 -186
  77. node v18.16/ts4.8/timers/promises.d.ts → node/ts4.8/timers/promises.d.ts +3 -3
  78. node v18.16/ts4.8/timers.d.ts → node/ts4.8/timers.d.ts +9 -2
  79. node v18.16/tls.d.ts → node/ts4.8/tls.d.ts +24 -16
  80. node v18.16/trace_events.d.ts → node/ts4.8/trace_events.d.ts +20 -9
  81. node v18.16/tty.d.ts → node/ts4.8/tty.d.ts +4 -5
  82. node v18.16/ts4.8/url.d.ts → node/ts4.8/url.d.ts +26 -36
  83. node v18.16/ts4.8/util.d.ts → node/ts4.8/util.d.ts +143 -116
  84. node v18.16/ts4.8/v8.d.ts → node/ts4.8/v8.d.ts +110 -16
  85. node v18.16/vm.d.ts → node/ts4.8/vm.d.ts +292 -42
  86. node v18.16/wasi.d.ts → node/ts4.8/wasi.d.ts +13 -19
  87. node v18.16/ts4.8/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +32 -34
  88. node v18.16/zlib.d.ts → node/ts4.8/zlib.d.ts +11 -11
  89. node v18.16/ts4.8/tty.d.ts → node/tty.d.ts +4 -5
  90. node v18.16/url.d.ts → node/url.d.ts +26 -36
  91. node v18.16/util.d.ts → node/util.d.ts +146 -111
  92. node v18.16/v8.d.ts → node/v8.d.ts +110 -16
  93. node v18.16/ts4.8/vm.d.ts → node/vm.d.ts +292 -42
  94. node v18.16/ts4.8/wasi.d.ts → node/wasi.d.ts +13 -19
  95. node v18.16/worker_threads.d.ts → node/worker_threads.d.ts +32 -34
  96. node v18.16/ts4.8/zlib.d.ts → node/zlib.d.ts +11 -11
  97. {node v18.16 → node}/LICENSE +0 -0
  98. {node v18.16 → node}/assert/strict.d.ts +0 -0
  99. {node v18.16 → node}/constants.d.ts +0 -0
  100. {node v18.16 → node}/dom-events.d.ts +0 -0
  101. {node v18.16 → node}/globals.d.ts +0 -0
  102. {node v18.16 → node}/globals.global.d.ts +0 -0
  103. {node v18.16 → node}/stream/promises.d.ts +0 -0
  104. {node v18.16 → node}/stream/web.d.ts +0 -0
  105. {node v18.16 → node}/ts4.8/assert/strict.d.ts +0 -0
  106. {node v18.16 → node}/ts4.8/constants.d.ts +0 -0
  107. {node v18.16 → node}/ts4.8/dom-events.d.ts +0 -0
  108. {node v18.16 → node}/ts4.8/globals.global.d.ts +0 -0
  109. {node v18.16 → node}/ts4.8/index.d.ts +0 -0
  110. {node v18.16 → node}/ts4.8/stream/promises.d.ts +0 -0
  111. {node v18.16 → node}/ts4.8/stream/web.d.ts +0 -0
@@ -1,17 +1,24 @@
1
1
  /**
2
- * The `async_hooks` module provides an API to track asynchronous resources. It
3
- * can be accessed using:
2
+ * We strongly discourage the use of the `async_hooks` API.
3
+ * Other APIs that can cover most of its use cases include:
4
+ *
5
+ * * `AsyncLocalStorage` tracks async context
6
+ * * `process.getActiveResourcesInfo()` tracks active resources
7
+ *
8
+ * The `node:async_hooks` module provides an API to track asynchronous resources.
9
+ * It can be accessed using:
4
10
  *
5
11
  * ```js
6
- * import async_hooks from 'async_hooks';
12
+ * import async_hooks from 'node:async_hooks';
7
13
  * ```
8
14
  * @experimental
9
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js)
15
+ * @see [source](https://github.com/nodejs/node/blob/v20.1.0/lib/async_hooks.js)
10
16
  */
11
17
  declare module 'async_hooks' {
12
18
  /**
13
19
  * ```js
14
- * import { executionAsyncId } from 'async_hooks';
20
+ * import { executionAsyncId } from 'node:async_hooks';
21
+ * import fs from 'node:fs';
15
22
  *
16
23
  * console.log(executionAsyncId()); // 1 - bootstrap
17
24
  * fs.open(path, 'r', (err, fd) => {
@@ -51,8 +58,8 @@ declare module 'async_hooks' {
51
58
  * but having an object representing the top-level can be helpful.
52
59
  *
53
60
  * ```js
54
- * import { open } from 'fs';
55
- * import { executionAsyncId, executionAsyncResource } from 'async_hooks';
61
+ * import { open } from 'node:fs';
62
+ * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
56
63
  *
57
64
  * console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
58
65
  * open(new URL(import.meta.url), 'r', (err, fd) => {
@@ -64,11 +71,11 @@ declare module 'async_hooks' {
64
71
  * use of a tracking `Map` to store the metadata:
65
72
  *
66
73
  * ```js
67
- * import { createServer } from 'http';
74
+ * import { createServer } from 'node:http';
68
75
  * import {
69
76
  * executionAsyncId,
70
77
  * executionAsyncResource,
71
- * createHook
78
+ * createHook,
72
79
  * } from 'async_hooks';
73
80
  * const sym = Symbol('state'); // Private symbol to avoid pollution
74
81
  *
@@ -78,7 +85,7 @@ declare module 'async_hooks' {
78
85
  * if (cr) {
79
86
  * resource[sym] = cr[sym];
80
87
  * }
81
- * }
88
+ * },
82
89
  * }).enable();
83
90
  *
84
91
  * const server = createServer((req, res) => {
@@ -167,11 +174,11 @@ declare module 'async_hooks' {
167
174
  * specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
168
175
  *
169
176
  * ```js
170
- * import { createHook } from 'async_hooks';
177
+ * import { createHook } from 'node:async_hooks';
171
178
  *
172
179
  * const asyncHook = createHook({
173
180
  * init(asyncId, type, triggerAsyncId, resource) { },
174
- * destroy(asyncId) { }
181
+ * destroy(asyncId) { },
175
182
  * });
176
183
  * ```
177
184
  *
@@ -223,13 +230,13 @@ declare module 'async_hooks' {
223
230
  * The following is an overview of the `AsyncResource` API.
224
231
  *
225
232
  * ```js
226
- * import { AsyncResource, executionAsyncId } from 'async_hooks';
233
+ * import { AsyncResource, executionAsyncId } from 'node:async_hooks';
227
234
  *
228
235
  * // AsyncResource() is meant to be extended. Instantiating a
229
236
  * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
230
237
  * // async_hook.executionAsyncId() is used.
231
238
  * const asyncResource = new AsyncResource(
232
- * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
239
+ * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
233
240
  * );
234
241
  *
235
242
  * // Run a function in the execution context of the resource. This will
@@ -263,9 +270,6 @@ declare module 'async_hooks' {
263
270
  constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
264
271
  /**
265
272
  * Binds the given function to the current execution context.
266
- *
267
- * The returned function will have an `asyncResource` property referencing
268
- * the `AsyncResource` to which the function is bound.
269
273
  * @since v14.8.0, v12.19.0
270
274
  * @param fn The function to bind to the current execution context.
271
275
  * @param type An optional name to associate with the underlying `AsyncResource`.
@@ -274,22 +278,15 @@ declare module 'async_hooks' {
274
278
  fn: Func,
275
279
  type?: string,
276
280
  thisArg?: ThisArg
277
- ): Func & {
278
- asyncResource: AsyncResource;
279
- };
281
+ ): Func;
280
282
  /**
281
283
  * Binds the given function to execute to this `AsyncResource`'s scope.
282
- *
283
- * The returned function will have an `asyncResource` property referencing
284
- * the `AsyncResource` to which the function is bound.
285
284
  * @since v14.8.0, v12.19.0
286
285
  * @param fn The function to bind to the current `AsyncResource`.
287
286
  */
288
287
  bind<Func extends (...args: any[]) => any>(
289
288
  fn: Func
290
- ): Func & {
291
- asyncResource: AsyncResource;
292
- };
289
+ ): Func;
293
290
  /**
294
291
  * Call the provided function with the provided arguments in the execution context
295
292
  * of the async resource. This will establish the context, trigger the AsyncHooks
@@ -322,17 +319,17 @@ declare module 'async_hooks' {
322
319
  /**
323
320
  * This class creates stores that stay coherent through asynchronous operations.
324
321
  *
325
- * While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
326
- * implementation that involves significant optimizations that are non-obvious to
327
- * implement.
322
+ * While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory
323
+ * safe implementation that involves significant optimizations that are non-obvious
324
+ * to implement.
328
325
  *
329
326
  * The following example uses `AsyncLocalStorage` to build a simple logger
330
327
  * that assigns IDs to incoming HTTP requests and includes them in messages
331
328
  * logged within each request.
332
329
  *
333
330
  * ```js
334
- * import http from 'http';
335
- * import { AsyncLocalStorage } from 'async_hooks';
331
+ * import http from 'node:http';
332
+ * import { AsyncLocalStorage } from 'node:async_hooks';
336
333
  *
337
334
  * const asyncLocalStorage = new AsyncLocalStorage();
338
335
  *
@@ -370,21 +367,44 @@ declare module 'async_hooks' {
370
367
  class AsyncLocalStorage<T> {
371
368
  /**
372
369
  * Binds the given function to the current execution context.
373
- * @since v18.16.0
370
+ * @since v19.8.0
371
+ * @experimental
374
372
  * @param fn The function to bind to the current execution context.
375
- * @returns A new function that calls `fn` within the captured execution context.
373
+ * @return A new function that calls `fn` within the captured execution context.
376
374
  */
377
- static bind<Func extends (...args: any[]) => any>(fn: Func): Func & {
378
- asyncResource: AsyncResource;
379
- };
375
+ static bind<Func extends (...args: any[]) => any>(
376
+ fn: Func
377
+ ): Func;
380
378
  /**
381
- * Captures the current execution context and returns a function that accepts a function as an argument.
382
- * Whenever the returned function is called, it calls the function passed to it within the captured context.
383
- * @since v18.16.0
379
+ * Captures the current execution context and returns a function that accepts a
380
+ * function as an argument. Whenever the returned function is called, it
381
+ * calls the function passed to it within the captured context.
382
+ *
383
+ * ```js
384
+ * const asyncLocalStorage = new AsyncLocalStorage();
385
+ * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
386
+ * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
387
+ * console.log(result); // returns 123
388
+ * ```
389
+ *
390
+ * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
391
+ * async context tracking purposes, for example:
392
+ *
393
+ * ```js
394
+ * class Foo {
395
+ * #runInAsyncScope = AsyncLocalStorage.snapshot();
396
+ *
397
+ * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
398
+ * }
399
+ *
400
+ * const foo = asyncLocalStorage.run(123, () => new Foo());
401
+ * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
402
+ * ```
403
+ * @since v19.8.0
404
+ * @experimental
405
+ * @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
384
406
  */
385
- static snapshot(): (<R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R) & {
386
- asyncResource: AsyncResource;
387
- };
407
+ static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
388
408
  /**
389
409
  * Disables the instance of `AsyncLocalStorage`. All subsequent calls
390
410
  * to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.