@types/node 16.11.39 → 18.11.2

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 v16.11 → node}/LICENSE +0 -0
  2. node v16.11/README.md → node/README.md +4 -4
  3. {node v16.11 → node}/assert/strict.d.ts +0 -0
  4. node v16.11/assert.d.ts → node/assert.d.ts +7 -8
  5. node v16.11/async_hooks.d.ts → node/async_hooks.d.ts +8 -4
  6. node/buffer.d.ts +2258 -0
  7. node v16.11/child_process.d.ts → node/child_process.d.ts +6 -3
  8. node v16.11/cluster.d.ts → node/cluster.d.ts +14 -18
  9. node v16.11/console.d.ts → node/console.d.ts +1 -1
  10. {node v16.11 → node}/constants.d.ts +0 -0
  11. node v16.11/crypto.d.ts → node/crypto.d.ts +679 -53
  12. node v16.11/dgram.d.ts → node/dgram.d.ts +3 -3
  13. node v16.11/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
  14. node v16.11/dns/promises.d.ts → node/dns/promises.d.ts +10 -8
  15. node v16.11/dns.d.ts → node/dns.d.ts +16 -11
  16. node/dom-events.d.ts +126 -0
  17. node v16.11/domain.d.ts → node/domain.d.ts +3 -2
  18. node v16.11/events.d.ts → node/events.d.ts +65 -10
  19. node v16.11/fs/promises.d.ts → node/fs/promises.d.ts +86 -39
  20. node v16.11/fs.d.ts → node/fs.d.ts +149 -67
  21. node/globals.d.ts +300 -0
  22. {node v16.11 → node}/globals.global.d.ts +0 -0
  23. node v16.11/http.d.ts → node/http.d.ts +305 -77
  24. node v16.11/http2.d.ts → node/http2.d.ts +38 -5
  25. node v16.11/https.d.ts → node/https.d.ts +209 -59
  26. node v16.11/index.d.ts → node/index.d.ts +6 -3
  27. node v16.11/inspector.d.ts → node/inspector.d.ts +11 -15
  28. {node v16.11 → node}/module.d.ts +0 -0
  29. node v16.11/net.d.ts → node/net.d.ts +94 -21
  30. node v16.11/os.d.ts → node/os.d.ts +15 -4
  31. node v16.11/package.json → node/package.json +15 -8
  32. node v16.11/path.d.ts → node/path.d.ts +34 -23
  33. node v16.11/perf_hooks.d.ts → node/perf_hooks.d.ts +76 -8
  34. node v16.11/process.d.ts → node/process.d.ts +17 -16
  35. node v16.11/punycode.d.ts → node/punycode.d.ts +1 -1
  36. node v16.11/querystring.d.ts → node/querystring.d.ts +4 -4
  37. node/readline/promises.d.ts +143 -0
  38. node v16.11/readline.d.ts → node/readline.d.ts +140 -30
  39. node v16.11/repl.d.ts → node/repl.d.ts +2 -2
  40. node v16.11/stream/consumers.d.ts → node/stream/consumers.d.ts +2 -14
  41. {node v16.11 → node}/stream/promises.d.ts +0 -0
  42. node v16.11/stream/web.d.ts → node/stream/web.d.ts +3 -65
  43. node v16.11/stream.d.ts → node/stream.d.ts +97 -19
  44. node v16.11/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
  45. node/test.d.ts +314 -0
  46. {node v16.11 → node}/timers/promises.d.ts +0 -0
  47. node v16.11/timers.d.ts → node/timers.d.ts +1 -1
  48. node v16.11/tls.d.ts → node/tls.d.ts +32 -23
  49. node v16.11/trace_events.d.ts → node/trace_events.d.ts +11 -1
  50. node/ts4.8/assert/strict.d.ts +8 -0
  51. node/ts4.8/assert.d.ts +911 -0
  52. node/ts4.8/async_hooks.d.ts +501 -0
  53. node v16.11/buffer.d.ts → node/ts4.8/buffer.d.ts +46 -19
  54. node/ts4.8/child_process.d.ts +1369 -0
  55. node/ts4.8/cluster.d.ts +410 -0
  56. node/ts4.8/console.d.ts +412 -0
  57. node/ts4.8/constants.d.ts +18 -0
  58. node/ts4.8/crypto.d.ts +3964 -0
  59. node/ts4.8/dgram.d.ts +545 -0
  60. node/ts4.8/diagnostics_channel.d.ts +153 -0
  61. node/ts4.8/dns/promises.d.ts +370 -0
  62. node/ts4.8/dns.d.ts +659 -0
  63. node/ts4.8/dom-events.d.ts +126 -0
  64. node/ts4.8/domain.d.ts +170 -0
  65. node/ts4.8/events.d.ts +678 -0
  66. node/ts4.8/fs/promises.d.ts +1138 -0
  67. node/ts4.8/fs.d.ts +3872 -0
  68. node v16.11/globals.d.ts → node/ts4.8/globals.d.ts +14 -4
  69. node/ts4.8/globals.global.d.ts +1 -0
  70. node/ts4.8/http.d.ts +1607 -0
  71. node/ts4.8/http2.d.ts +2134 -0
  72. node/ts4.8/https.d.ts +541 -0
  73. node/ts4.8/index.d.ts +88 -0
  74. node/ts4.8/inspector.d.ts +2741 -0
  75. node/ts4.8/module.d.ts +114 -0
  76. node/ts4.8/net.d.ts +869 -0
  77. node/ts4.8/os.d.ts +466 -0
  78. node/ts4.8/path.d.ts +191 -0
  79. node/ts4.8/perf_hooks.d.ts +625 -0
  80. node/ts4.8/process.d.ts +1482 -0
  81. node/ts4.8/punycode.d.ts +117 -0
  82. node/ts4.8/querystring.d.ts +131 -0
  83. node/ts4.8/readline/promises.d.ts +143 -0
  84. node/ts4.8/readline.d.ts +653 -0
  85. node/ts4.8/repl.d.ts +424 -0
  86. node/ts4.8/stream/consumers.d.ts +12 -0
  87. node/ts4.8/stream/promises.d.ts +42 -0
  88. node/ts4.8/stream/web.d.ts +330 -0
  89. node/ts4.8/stream.d.ts +1340 -0
  90. node/ts4.8/string_decoder.d.ts +67 -0
  91. node/ts4.8/test.d.ts +314 -0
  92. node/ts4.8/timers/promises.d.ts +68 -0
  93. node/ts4.8/timers.d.ts +94 -0
  94. node/ts4.8/tls.d.ts +1028 -0
  95. node/ts4.8/trace_events.d.ts +171 -0
  96. node v16.11/tty.d.ts → node/ts4.8/tty.d.ts +4 -2
  97. node v16.11/url.d.ts → node/ts4.8/url.d.ts +85 -39
  98. node v16.11/util.d.ts → node/ts4.8/util.d.ts +268 -12
  99. node v16.11/v8.d.ts → node/ts4.8/v8.d.ts +21 -3
  100. node v16.11/vm.d.ts → node/ts4.8/vm.d.ts +6 -4
  101. node v16.11/wasi.d.ts → node/ts4.8/wasi.d.ts +1 -1
  102. node v16.11/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +50 -10
  103. node v16.11/zlib.d.ts → node/ts4.8/zlib.d.ts +1 -1
  104. node/tty.d.ts +206 -0
  105. node/url.d.ts +897 -0
  106. node/util.d.ts +1850 -0
  107. node/v8.d.ts +396 -0
  108. node/vm.d.ts +509 -0
  109. node/wasi.d.ts +158 -0
  110. node/worker_threads.d.ts +689 -0
  111. node/zlib.d.ts +517 -0
@@ -6,7 +6,7 @@
6
6
  * ```js
7
7
  * const util = require('util');
8
8
  * ```
9
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/util.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/util.js)
10
10
  */
11
11
  declare module 'util' {
12
12
  import * as types from 'node:util/types';
@@ -139,7 +139,7 @@ declare module 'util' {
139
139
  * console.error(name); // ENOENT
140
140
  * });
141
141
  * ```
142
- * @since v16.0.0
142
+ * @since v16.0.0, v14.17.0
143
143
  */
144
144
  export function getSystemErrorMap(): Map<number, [string, string]>;
145
145
  /**
@@ -159,9 +159,30 @@ declare module 'util' {
159
159
  * Returns the `string` after replacing any surrogate code points
160
160
  * (or equivalently, any unpaired surrogate code units) with the
161
161
  * Unicode "replacement character" U+FFFD.
162
- * @since v16.8.0
162
+ * @since v16.8.0, v14.18.0
163
163
  */
164
164
  export function toUSVString(string: string): string;
165
+ /**
166
+ * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
167
+ * as transferable and can be used with `structuredClone()` or `postMessage()`.
168
+ * @since v18.11.0
169
+ * @returns A transferable AbortController
170
+ */
171
+ export function transferableAbortController(): AbortController;
172
+ /**
173
+ * Marks the given {AbortSignal} as transferable so that it can be used with
174
+ * `structuredClone()` and `postMessage()`.
175
+ *
176
+ * ```js
177
+ * const signal = transferableAbortSignal(AbortSignal.timeout(100));
178
+ * const channel = new MessageChannel();
179
+ * channel.port2.postMessage(signal, [signal]);
180
+ * ```
181
+ * @since v18.11.0
182
+ * @param signal The AbortSignal
183
+ * @returns The same AbortSignal
184
+ */
185
+ export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
165
186
  /**
166
187
  * The `util.inspect()` method returns a string representation of `object` that is
167
188
  * intended for debugging. The output of `util.inspect` may change at any time
@@ -309,6 +330,21 @@ declare module 'util' {
309
330
  * );
310
331
  * ```
311
332
  *
333
+ * The `numericSeparator` option adds an underscore every three digits to all
334
+ * numbers.
335
+ *
336
+ * ```js
337
+ * const { inspect } = require('util');
338
+ *
339
+ * const thousand = 1_000;
340
+ * const million = 1_000_000;
341
+ * const bigNumber = 123_456_789n;
342
+ * const bigDecimal = 1_234.123_45;
343
+ *
344
+ * console.log(thousand, million, bigNumber, bigDecimal);
345
+ * // 1_000 1_000_000 123_456_789n 1_234.123_45
346
+ * ```
347
+ *
312
348
  * `util.inspect()` is a synchronous method intended for debugging. Its maximum
313
349
  * output length is approximately 128 MB. Inputs that result in longer output will
314
350
  * be truncated.
@@ -317,7 +353,7 @@ declare module 'util' {
317
353
  * @return The representation of `object`.
318
354
  */
319
355
  export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
320
- export function inspect(object: any, options: InspectOptions): string;
356
+ export function inspect(object: any, options?: InspectOptions): string;
321
357
  export namespace inspect {
322
358
  let colors: NodeJS.Dict<[number, number]>;
323
359
  let styles: {
@@ -859,7 +895,7 @@ declare module 'util' {
859
895
  * callbackFunction((err, ret) => {
860
896
  * // When the Promise was rejected with `null` it is wrapped with an Error and
861
897
  * // the original value is stored in `reason`.
862
- * err &#x26;&#x26; err.hasOwnProperty('reason') &#x26;&#x26; err.reason === null; // true
898
+ * err &#x26;&#x26; Object.hasOwn(err, 'reason') &#x26;&#x26; err.reason === null; // true
863
899
  * });
864
900
  * ```
865
901
  * @since v8.2.0
@@ -998,13 +1034,9 @@ declare module 'util' {
998
1034
  * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
999
1035
  *
1000
1036
  * ```js
1001
- * const decoder = new TextDecoder('shift_jis');
1002
- * let string = '';
1003
- * let buffer;
1004
- * while (buffer = getNextChunkSomehow()) {
1005
- * string += decoder.decode(buffer, { stream: true });
1006
- * }
1007
- * string += decoder.decode(); // end-of-stream
1037
+ * const decoder = new TextDecoder();
1038
+ * const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
1039
+ * console.log(decoder.decode(u8arr)); // Hello
1008
1040
  * ```
1009
1041
  * @since v8.3.0
1010
1042
  */
@@ -1056,6 +1088,8 @@ declare module 'util' {
1056
1088
  written: number;
1057
1089
  }
1058
1090
  export { types };
1091
+
1092
+ //// TextEncoder/Decoder
1059
1093
  /**
1060
1094
  * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
1061
1095
  * instances of `TextEncoder` only support UTF-8 encoding.
@@ -1094,6 +1128,228 @@ declare module 'util' {
1094
1128
  */
1095
1129
  encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
1096
1130
  }
1131
+
1132
+ import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'util';
1133
+ global {
1134
+ /**
1135
+ * `TextDecoder` class is a global reference for `require('util').TextDecoder`
1136
+ * https://nodejs.org/api/globals.html#textdecoder
1137
+ * @since v11.0.0
1138
+ */
1139
+ var TextDecoder: typeof globalThis extends {
1140
+ onmessage: any;
1141
+ TextDecoder: infer TextDecoder;
1142
+ }
1143
+ ? TextDecoder
1144
+ : typeof _TextDecoder;
1145
+
1146
+ /**
1147
+ * `TextEncoder` class is a global reference for `require('util').TextEncoder`
1148
+ * https://nodejs.org/api/globals.html#textencoder
1149
+ * @since v11.0.0
1150
+ */
1151
+ var TextEncoder: typeof globalThis extends {
1152
+ onmessage: any;
1153
+ TextEncoder: infer TextEncoder;
1154
+ }
1155
+ ? TextEncoder
1156
+ : typeof _TextEncoder;
1157
+ }
1158
+
1159
+ //// parseArgs
1160
+ /**
1161
+ * Provides a high-level API for command-line argument parsing. Takes a
1162
+ * specification for the expected arguments and returns a structured object
1163
+ * with the parsed values and positionals.
1164
+ *
1165
+ * `config` provides arguments for parsing and configures the parser. It
1166
+ * supports the following properties:
1167
+ *
1168
+ * - `args` The array of argument strings. **Default:** `process.argv` with
1169
+ * `execPath` and `filename` removed.
1170
+ * - `options` Arguments known to the parser. Keys of `options` are the long
1171
+ * names of options and values are objects accepting the following properties:
1172
+ *
1173
+ * - `type` Type of argument, which must be either `boolean` (for options
1174
+ * which do not take values) or `string` (for options which do).
1175
+ * - `multiple` Whether this option can be provided multiple
1176
+ * times. If `true`, all values will be collected in an array. If
1177
+ * `false`, values for the option are last-wins. **Default:** `false`.
1178
+ * - `short` A single character alias for the option.
1179
+ * - `default` The default option value when it is not set by args. It
1180
+ * must be of the same type as the `type` property. When `multiple`
1181
+ * is `true`, it must be an array.
1182
+ *
1183
+ * - `strict`: Whether an error should be thrown when unknown arguments
1184
+ * are encountered, or when arguments are passed that do not match the
1185
+ * `type` configured in `options`. **Default:** `true`.
1186
+ * - `allowPositionals`: Whether this command accepts positional arguments.
1187
+ * **Default:** `false` if `strict` is `true`, otherwise `true`.
1188
+ * - `tokens`: Whether tokens {boolean} Return the parsed tokens. This is useful
1189
+ * for extending the built-in behavior, from adding additional checks through
1190
+ * to reprocessing the tokens in different ways.
1191
+ * **Default:** `false`.
1192
+ *
1193
+ * @returns The parsed command line arguments:
1194
+ *
1195
+ * - `values` A mapping of parsed option names with their string
1196
+ * or boolean values.
1197
+ * - `positionals` Positional arguments.
1198
+ * - `tokens` Detailed parse information (only if `tokens` was specified).
1199
+ *
1200
+ */
1201
+ export function parseArgs<T extends ParseArgsConfig>(config: T): ParsedResults<T>;
1202
+
1203
+ interface ParseArgsOptionConfig {
1204
+ type: 'string' | 'boolean';
1205
+ short?: string;
1206
+ multiple?: boolean;
1207
+ /**
1208
+ * @since v18.11.0
1209
+ */
1210
+ default?: string | boolean | string[] | boolean[];
1211
+ }
1212
+
1213
+ interface ParseArgsOptionsConfig {
1214
+ [longOption: string]: ParseArgsOptionConfig;
1215
+ }
1216
+
1217
+ export interface ParseArgsConfig {
1218
+ strict?: boolean;
1219
+ allowPositionals?: boolean;
1220
+ tokens?: boolean;
1221
+ options?: ParseArgsOptionsConfig;
1222
+ args?: string[];
1223
+ }
1224
+
1225
+ /*
1226
+ IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties.
1227
+ TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936
1228
+ This means it is impossible to distinguish between "field X is definitely not present" and "field X may or may not be present".
1229
+ But we expect users to generally provide their config inline or `as const`, which means TS will always know whether a given field is present.
1230
+ So this helper treats "not definitely present" (i.e., not `extends boolean`) as being "definitely not present", i.e. it should have its default value.
1231
+ This is technically incorrect but is a much nicer UX for the common case.
1232
+ The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false.
1233
+ */
1234
+ type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true
1235
+ ? IfTrue
1236
+ : T extends false
1237
+ ? IfFalse
1238
+ : IfTrue;
1239
+
1240
+ // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
1241
+ type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false
1242
+ ? IfFalse
1243
+ : T extends true
1244
+ ? IfTrue
1245
+ : IfFalse;
1246
+
1247
+ type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionConfig> = IfDefaultsTrue<
1248
+ T['strict'],
1249
+ O['type'] extends 'string' ? string : O['type'] extends 'boolean' ? boolean : string | boolean,
1250
+ string | boolean
1251
+ >;
1252
+
1253
+ type ParsedValues<T extends ParseArgsConfig> =
1254
+ & IfDefaultsTrue<T['strict'], unknown, { [longOption: string]: undefined | string | boolean }>
1255
+ & (T['options'] extends ParseArgsOptionsConfig
1256
+ ? {
1257
+ -readonly [LongOption in keyof T['options']]: IfDefaultsFalse<
1258
+ T['options'][LongOption]['multiple'],
1259
+ undefined | Array<ExtractOptionValue<T, T['options'][LongOption]>>,
1260
+ undefined | ExtractOptionValue<T, T['options'][LongOption]>
1261
+ >;
1262
+ }
1263
+ : {});
1264
+
1265
+ type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
1266
+ T['strict'],
1267
+ IfDefaultsFalse<T['allowPositionals'], string[], []>,
1268
+ IfDefaultsTrue<T['allowPositionals'], string[], []>
1269
+ >;
1270
+
1271
+ type PreciseTokenForOptions<
1272
+ K extends string,
1273
+ O extends ParseArgsOptionConfig,
1274
+ > = O['type'] extends 'string'
1275
+ ? {
1276
+ kind: 'option';
1277
+ index: number;
1278
+ name: K;
1279
+ rawName: string;
1280
+ value: string;
1281
+ inlineValue: boolean;
1282
+ }
1283
+ : O['type'] extends 'boolean'
1284
+ ? {
1285
+ kind: 'option';
1286
+ index: number;
1287
+ name: K;
1288
+ rawName: string;
1289
+ value: undefined;
1290
+ inlineValue: undefined;
1291
+ }
1292
+ : OptionToken & { name: K };
1293
+
1294
+ type TokenForOptions<
1295
+ T extends ParseArgsConfig,
1296
+ K extends keyof T['options'] = keyof T['options'],
1297
+ > = K extends unknown
1298
+ ? T['options'] extends ParseArgsOptionsConfig
1299
+ ? PreciseTokenForOptions<K & string, T['options'][K]>
1300
+ : OptionToken
1301
+ : never;
1302
+
1303
+ type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T['strict'], TokenForOptions<T>, OptionToken>;
1304
+
1305
+ type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1306
+ T['strict'],
1307
+ IfDefaultsFalse<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>,
1308
+ IfDefaultsTrue<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>
1309
+ >;
1310
+
1311
+ type ParsedTokens<T extends ParseArgsConfig> = Array<
1312
+ ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: 'option-terminator'; index: number }
1313
+ >;
1314
+
1315
+ type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1316
+ T['tokens'],
1317
+ {
1318
+ values: ParsedValues<T>;
1319
+ positionals: ParsedPositionals<T>;
1320
+ tokens: ParsedTokens<T>;
1321
+ },
1322
+ {
1323
+ values: ParsedValues<T>;
1324
+ positionals: ParsedPositionals<T>;
1325
+ }
1326
+ >;
1327
+
1328
+ type OptionToken =
1329
+ | { kind: 'option'; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1330
+ | {
1331
+ kind: 'option';
1332
+ index: number;
1333
+ name: string;
1334
+ rawName: string;
1335
+ value: undefined;
1336
+ inlineValue: undefined;
1337
+ };
1338
+
1339
+ type Token =
1340
+ | OptionToken
1341
+ | { kind: 'positional'; index: number; value: string }
1342
+ | { kind: 'option-terminator'; index: number };
1343
+
1344
+ // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
1345
+ // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
1346
+ type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T
1347
+ ? {
1348
+ values: { [longOption: string]: undefined | string | boolean | Array<string | boolean> };
1349
+ positionals: string[];
1350
+ tokens?: Token[];
1351
+ }
1352
+ : PreciseParsedResults<T>;
1097
1353
  }
1098
1354
  declare module 'util/types' {
1099
1355
  export * from 'util/types';
@@ -4,7 +4,7 @@
4
4
  * ```js
5
5
  * const v8 = require('v8');
6
6
  * ```
7
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/v8.js)
7
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js)
8
8
  */
9
9
  declare module 'v8' {
10
10
  import { Readable } from 'node:stream';
@@ -163,6 +163,13 @@ declare module 'v8' {
163
163
  * Chrome DevTools. The JSON schema is undocumented and specific to the
164
164
  * V8 engine. Therefore, the schema may change from one version of V8 to the next.
165
165
  *
166
+ * Creating a heap snapshot requires memory about twice the size of the heap at
167
+ * the time the snapshot is created. This results in the risk of OOM killers
168
+ * terminating the process.
169
+ *
170
+ * Generating a snapshot is a synchronous operation which blocks the event loop
171
+ * for a duration depending on the heap size.
172
+ *
166
173
  * ```js
167
174
  * // Print heap snapshot to the console
168
175
  * const v8 = require('v8');
@@ -182,6 +189,13 @@ declare module 'v8' {
182
189
  * A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
183
190
  * not contain any information about the workers, and vice versa.
184
191
  *
192
+ * Creating a heap snapshot requires memory about twice the size of the heap at
193
+ * the time the snapshot is created. This results in the risk of OOM killers
194
+ * terminating the process.
195
+ *
196
+ * Generating a snapshot is a synchronous operation which blocks the event loop
197
+ * for a duration depending on the heap size.
198
+ *
185
199
  * ```js
186
200
  * const { writeHeapSnapshot } = require('v8');
187
201
  * const {
@@ -344,6 +358,10 @@ declare module 'v8' {
344
358
  class DefaultDeserializer extends Deserializer {}
345
359
  /**
346
360
  * Uses a `DefaultSerializer` to serialize `value` into a buffer.
361
+ *
362
+ * `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
363
+ * serialize a huge object which requires buffer
364
+ * larger than `buffer.constants.MAX_LENGTH`.
347
365
  * @since v8.0.0
348
366
  */
349
367
  function serialize(value: any): Buffer;
@@ -362,14 +380,14 @@ declare module 'v8' {
362
380
  *
363
381
  * When the process is about to exit, one last coverage will still be written to
364
382
  * disk unless {@link stopCoverage} is invoked before the process exits.
365
- * @since v15.1.0, v12.22.0
383
+ * @since v15.1.0, v14.18.0, v12.22.0
366
384
  */
367
385
  function takeCoverage(): void;
368
386
  /**
369
387
  * The `v8.stopCoverage()` method allows the user to stop the coverage collection
370
388
  * started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
371
389
  * records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
372
- * @since v15.1.0, v12.22.0
390
+ * @since v15.1.0, v14.18.0, v12.22.0
373
391
  */
374
392
  function stopCoverage(): void;
375
393
  }
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * The `vm` module enables compiling and running code within V8 Virtual
3
- * Machine contexts. **The `vm` module is not a security mechanism. Do**
4
- * **not use it to run untrusted code.**
3
+ * Machine contexts.
4
+ *
5
+ * **The `vm` module is not a security**
6
+ * **mechanism. Do not use it to run untrusted code.**
5
7
  *
6
8
  * JavaScript code can be compiled and run immediately or
7
9
  * compiled, saved, and run later.
@@ -32,7 +34,7 @@
32
34
  *
33
35
  * console.log(x); // 1; y is not defined.
34
36
  * ```
35
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/vm.js)
37
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js)
36
38
  */
37
39
  declare module 'vm' {
38
40
  interface Context extends NodeJS.Dict<any> {}
@@ -221,7 +223,7 @@ declare module 'vm' {
221
223
  runInNewContext(contextObject?: Context, options?: RunningScriptOptions): any;
222
224
  /**
223
225
  * Runs the compiled code contained by the `vm.Script` within the context of the
224
- * current `global` object. Running code does not have access to local scope, but_does_ have access to the current `global` object.
226
+ * current `global` object. Running code does not have access to local scope, but _does_ have access to the current `global` object.
225
227
  *
226
228
  * The following example compiles code that increments a `global` variable then
227
229
  * executes that code multiple times:
@@ -68,7 +68,7 @@
68
68
  * The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
69
69
  * example to run.
70
70
  * @experimental
71
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/wasi.js)
71
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/wasi.js)
72
72
  */
73
73
  declare module 'wasi' {
74
74
  interface WASIOptions {
@@ -39,7 +39,7 @@
39
39
  * }
40
40
  * ```
41
41
  *
42
- * The above example spawns a Worker thread for each `parse()` call. In actual
42
+ * The above example spawns a Worker thread for each `parseJSAsync()` call. In
43
43
  * practice, use a pool of Workers for these kinds of tasks. Otherwise, the
44
44
  * overhead of creating Workers would likely exceed their benefit.
45
45
  *
@@ -49,7 +49,7 @@
49
49
  *
50
50
  * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
51
51
  * specifically `argv` and `execArgv` options.
52
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/worker_threads.js)
52
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/worker_threads.js)
53
53
  */
54
54
  declare module 'worker_threads' {
55
55
  import { Blob } from 'node:buffer';
@@ -175,7 +175,7 @@ declare module 'worker_threads' {
175
175
  */
176
176
  postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
177
177
  /**
178
- * Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does_not_ let the program exit if it's the only active handle left (the default
178
+ * Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
179
179
  * behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
180
180
  *
181
181
  * If listeners are attached or removed using `.on('message')`, the port
@@ -384,7 +384,7 @@ declare module 'worker_threads' {
384
384
  /**
385
385
  * An object that can be used to query performance information from a worker
386
386
  * instance. Similar to `perf_hooks.performance`.
387
- * @since v15.1.0, v12.22.0
387
+ * @since v15.1.0, v14.17.0, v12.22.0
388
388
  */
389
389
  readonly performance: WorkerPerformance;
390
390
  /**
@@ -400,7 +400,7 @@ declare module 'worker_threads' {
400
400
  */
401
401
  postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
402
402
  /**
403
- * Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does_not_ let the program exit if it's the only active handle left (the default
403
+ * Opposite of `unref()`, calling `ref()` on a previously `unref()`ed worker does _not_ let the program exit if it's the only active handle left (the default
404
404
  * behavior). If the worker is `ref()`ed, calling `ref()` again has
405
405
  * no effect.
406
406
  * @since v10.5.0
@@ -507,7 +507,6 @@ declare module 'worker_threads' {
507
507
  * }
508
508
  * ```
509
509
  * @since v15.4.0
510
- * @experimental
511
510
  */
512
511
  class BroadcastChannel {
513
512
  readonly name: string;
@@ -629,20 +628,61 @@ declare module 'worker_threads' {
629
628
  * console.log(getEnvironmentData('Hello')); // Prints 'World!'.
630
629
  * }
631
630
  * ```
632
- * @since v15.12.0
633
- * @experimental
631
+ * @since v15.12.0, v14.18.0
634
632
  * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
635
633
  */
636
634
  function getEnvironmentData(key: Serializable): Serializable;
637
635
  /**
638
636
  * The `worker.setEnvironmentData()` API sets the content of`worker.getEnvironmentData()` in the current thread and all new `Worker`instances spawned from the current context.
639
- * @since v15.12.0
640
- * @experimental
637
+ * @since v15.12.0, v14.18.0
641
638
  * @param key Any arbitrary, cloneable JavaScript value that can be used as a {Map} key.
642
639
  * @param value Any arbitrary, cloneable JavaScript value that will be cloned and passed automatically to all new `Worker` instances. If `value` is passed as `undefined`, any previously set value
643
640
  * for the `key` will be deleted.
644
641
  */
645
642
  function setEnvironmentData(key: Serializable, value: Serializable): void;
643
+
644
+ import {
645
+ BroadcastChannel as _BroadcastChannel,
646
+ MessageChannel as _MessageChannel,
647
+ MessagePort as _MessagePort,
648
+ } from 'worker_threads';
649
+ global {
650
+ /**
651
+ * `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel`
652
+ * https://nodejs.org/api/globals.html#broadcastchannel
653
+ * @since v18.0.0
654
+ */
655
+ var BroadcastChannel: typeof globalThis extends {
656
+ onmessage: any;
657
+ BroadcastChannel: infer T;
658
+ }
659
+ ? T
660
+ : typeof _BroadcastChannel;
661
+
662
+ /**
663
+ * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
664
+ * https://nodejs.org/api/globals.html#messagechannel
665
+ * @since v15.0.0
666
+ */
667
+ var MessageChannel: typeof globalThis extends {
668
+ onmessage: any;
669
+ MessageChannel: infer T;
670
+ }
671
+ ? T
672
+ : typeof _MessageChannel;
673
+
674
+ /**
675
+ * `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
676
+ * https://nodejs.org/api/globals.html#messageport
677
+ * @since v15.0.0
678
+ */
679
+ var MessagePort: typeof globalThis extends {
680
+ onmessage: any;
681
+ MessagePort: infer T;
682
+ }
683
+ ? T
684
+ : typeof _MessagePort;
685
+ }
646
686
  }
647
687
  declare module 'node:worker_threads' {
648
688
  export * from 'worker_threads';
@@ -88,7 +88,7 @@
88
88
  * });
89
89
  * ```
90
90
  * @since v0.5.8
91
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/zlib.js)
91
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/zlib.js)
92
92
  */
93
93
  declare module 'zlib' {
94
94
  import * as stream from 'node:stream';