@types/node 16.18.110 → 16.18.112

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 (46) hide show
  1. node v16.18/README.md +1 -1
  2. node v16.18/buffer.buffer.d.ts +365 -0
  3. node v16.18/buffer.d.ts +8 -362
  4. node v16.18/child_process.d.ts +34 -29
  5. node v16.18/cluster.d.ts +1 -1
  6. node v16.18/console.d.ts +2 -2
  7. node v16.18/crypto.d.ts +1 -1
  8. node v16.18/dns/promises.d.ts +6 -5
  9. node v16.18/dns.d.ts +5 -5
  10. node v16.18/domain.d.ts +2 -2
  11. node v16.18/events.d.ts +13 -13
  12. node v16.18/fs/promises.d.ts +2 -2
  13. node v16.18/fs.d.ts +1 -1
  14. node v16.18/globals.d.ts +0 -14
  15. node v16.18/globals.typedarray.d.ts +21 -0
  16. node v16.18/http.d.ts +2 -2
  17. node v16.18/http2.d.ts +24 -24
  18. node v16.18/https.d.ts +9 -9
  19. node v16.18/index.d.ts +5 -1
  20. node v16.18/inspector.d.ts +1 -1
  21. node v16.18/module.d.ts +3 -3
  22. node v16.18/net.d.ts +2 -2
  23. node v16.18/os.d.ts +1 -1
  24. node v16.18/package.json +9 -2
  25. node v16.18/path.d.ts +1 -1
  26. node v16.18/perf_hooks.d.ts +11 -11
  27. node v16.18/punycode.d.ts +1 -1
  28. node v16.18/querystring.d.ts +1 -1
  29. node v16.18/readline.d.ts +12 -12
  30. node v16.18/repl.d.ts +4 -4
  31. node v16.18/stream.d.ts +18 -18
  32. node v16.18/string_decoder.d.ts +3 -3
  33. node v16.18/timers/promises.d.ts +1 -1
  34. node v16.18/timers.d.ts +1 -1
  35. node v16.18/tls.d.ts +5 -5
  36. node v16.18/trace_events.d.ts +3 -3
  37. node v16.18/ts5.6/buffer.buffer.d.ts +365 -0
  38. node v16.18/ts5.6/globals.typedarray.d.ts +19 -0
  39. node v16.18/ts5.6/index.d.ts +90 -0
  40. node v16.18/tty.d.ts +1 -1
  41. node v16.18/url.d.ts +6 -6
  42. node v16.18/util.d.ts +40 -40
  43. node v16.18/v8.d.ts +11 -11
  44. node v16.18/vm.d.ts +11 -12
  45. node v16.18/worker_threads.d.ts +19 -19
  46. node v16.18/zlib.d.ts +8 -8
node v16.18/util.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * it:
5
5
  *
6
6
  * ```js
7
- * const util = require('util');
7
+ * import util from 'node:util';
8
8
  * ```
9
9
  * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/util.js)
10
10
  */
@@ -158,7 +158,7 @@ declare module "util" {
158
158
  * timestamp.
159
159
  *
160
160
  * ```js
161
- * const util = require('util');
161
+ * import util from 'node:util';
162
162
  *
163
163
  * util.log('Timestamped message.');
164
164
  * ```
@@ -199,7 +199,7 @@ declare module "util" {
199
199
  * Circular references point to their anchor by using a reference index:
200
200
  *
201
201
  * ```js
202
- * const { inspect } = require('util');
202
+ * import { inspect } from 'node:util';
203
203
  *
204
204
  * const obj = {};
205
205
  * obj.a = [obj];
@@ -217,7 +217,7 @@ declare module "util" {
217
217
  * The following example inspects all properties of the `util` object:
218
218
  *
219
219
  * ```js
220
- * const util = require('util');
220
+ * import util from 'node:util';
221
221
  *
222
222
  * console.log(util.inspect(util, { showHidden: true, depth: null }));
223
223
  * ```
@@ -225,7 +225,7 @@ declare module "util" {
225
225
  * The following example highlights the effect of the `compact` option:
226
226
  *
227
227
  * ```js
228
- * const util = require('util');
228
+ * import util from 'node:util';
229
229
  *
230
230
  * const o = {
231
231
  * a: [1, 2, [[
@@ -282,7 +282,7 @@ declare module "util" {
282
282
  * with no remaining strong references may be garbage collected at any time.
283
283
  *
284
284
  * ```js
285
- * const { inspect } = require('util');
285
+ * import { inspect } from 'node:util';
286
286
  *
287
287
  * const obj = { a: 1 };
288
288
  * const obj2 = { b: 2 };
@@ -296,8 +296,8 @@ declare module "util" {
296
296
  * impact the result of `util.inspect()`.
297
297
  *
298
298
  * ```js
299
- * const { inspect } = require('util');
300
- * const assert = require('assert');
299
+ * import { inspect } from 'node:util';
300
+ * import assert from 'node:assert';
301
301
  *
302
302
  * const o1 = {
303
303
  * b: [2, 3, 1],
@@ -350,7 +350,7 @@ declare module "util" {
350
350
  * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
351
351
  *
352
352
  * ```js
353
- * const util = require('util');
353
+ * import util from 'node:util';
354
354
  *
355
355
  * util.isArray([]);
356
356
  * // Returns: true
@@ -367,7 +367,7 @@ declare module "util" {
367
367
  * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
368
368
  *
369
369
  * ```js
370
- * const util = require('util');
370
+ * import util from 'node:util';
371
371
  *
372
372
  * util.isRegExp(/some regexp/);
373
373
  * // Returns: true
@@ -384,7 +384,7 @@ declare module "util" {
384
384
  * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
385
385
  *
386
386
  * ```js
387
- * const util = require('util');
387
+ * import util from 'node:util';
388
388
  *
389
389
  * util.isDate(new Date());
390
390
  * // Returns: true
@@ -401,7 +401,7 @@ declare module "util" {
401
401
  * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`.
402
402
  *
403
403
  * ```js
404
- * const util = require('util');
404
+ * import util from 'node:util';
405
405
  *
406
406
  * util.isError(new Error());
407
407
  * // Returns: true
@@ -415,7 +415,7 @@ declare module "util" {
415
415
  * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`.
416
416
  *
417
417
  * ```js
418
- * const util = require('util');
418
+ * import util from 'node:util';
419
419
  * const obj = { name: 'Error', message: 'an error occurred' };
420
420
  *
421
421
  * util.isError(obj);
@@ -440,8 +440,8 @@ declare module "util" {
440
440
  * through the `constructor.super_` property.
441
441
  *
442
442
  * ```js
443
- * const util = require('util');
444
- * const EventEmitter = require('events');
443
+ * import util from 'node:util';
444
+ * import EventEmitter from 'node:events';
445
445
  *
446
446
  * function MyStream() {
447
447
  * EventEmitter.call(this);
@@ -467,7 +467,7 @@ declare module "util" {
467
467
  * ES6 example using `class` and `extends`:
468
468
  *
469
469
  * ```js
470
- * const EventEmitter = require('events');
470
+ * import EventEmitter from 'node:events';
471
471
  *
472
472
  * class MyStream extends EventEmitter {
473
473
  * write(data) {
@@ -496,7 +496,7 @@ declare module "util" {
496
496
  * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
497
497
  *
498
498
  * ```js
499
- * const util = require('util');
499
+ * import util from 'node:util';
500
500
  * const debuglog = util.debuglog('foo');
501
501
  *
502
502
  * debuglog('hello from foo [%d]', 123);
@@ -515,7 +515,7 @@ declare module "util" {
515
515
  * The `section` supports wildcard also:
516
516
  *
517
517
  * ```js
518
- * const util = require('util');
518
+ * import util from 'node:util';
519
519
  * const debuglog = util.debuglog('foo-bar');
520
520
  *
521
521
  * debuglog('hi there, it\'s foo-bar [%d]', 2333);
@@ -535,7 +535,7 @@ declare module "util" {
535
535
  * unnecessary wrapping.
536
536
  *
537
537
  * ```js
538
- * const util = require('util');
538
+ * import util from 'node:util';
539
539
  * let debuglog = util.debuglog('internals', (debug) => {
540
540
  * // Replace with a logging function that optimizes out
541
541
  * // testing if the section is enabled
@@ -553,7 +553,7 @@ declare module "util" {
553
553
  * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
554
554
  *
555
555
  * ```js
556
- * const util = require('util');
556
+ * import util from 'node:util';
557
557
  *
558
558
  * util.isBoolean(1);
559
559
  * // Returns: false
@@ -570,7 +570,7 @@ declare module "util" {
570
570
  * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
571
571
  *
572
572
  * ```js
573
- * const util = require('util');
573
+ * import util from 'node:util';
574
574
  *
575
575
  * util.isBuffer({ length: 0 });
576
576
  * // Returns: false
@@ -587,7 +587,7 @@ declare module "util" {
587
587
  * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`.
588
588
  *
589
589
  * ```js
590
- * const util = require('util');
590
+ * import util from 'node:util';
591
591
  *
592
592
  * function Foo() {}
593
593
  * const Bar = () => {};
@@ -607,7 +607,7 @@ declare module "util" {
607
607
  * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
608
608
  *
609
609
  * ```js
610
- * const util = require('util');
610
+ * import util from 'node:util';
611
611
  *
612
612
  * util.isNull(0);
613
613
  * // Returns: false
@@ -625,7 +625,7 @@ declare module "util" {
625
625
  * returns `false`.
626
626
  *
627
627
  * ```js
628
- * const util = require('util');
628
+ * import util from 'node:util';
629
629
  *
630
630
  * util.isNullOrUndefined(0);
631
631
  * // Returns: false
@@ -642,7 +642,7 @@ declare module "util" {
642
642
  * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
643
643
  *
644
644
  * ```js
645
- * const util = require('util');
645
+ * import util from 'node:util';
646
646
  *
647
647
  * util.isNumber(false);
648
648
  * // Returns: false
@@ -662,7 +662,7 @@ declare module "util" {
662
662
  * Otherwise, returns `false`.
663
663
  *
664
664
  * ```js
665
- * const util = require('util');
665
+ * import util from 'node:util';
666
666
  *
667
667
  * util.isObject(5);
668
668
  * // Returns: false
@@ -681,7 +681,7 @@ declare module "util" {
681
681
  * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
682
682
  *
683
683
  * ```js
684
- * const util = require('util');
684
+ * import util from 'node:util';
685
685
  *
686
686
  * util.isPrimitive(5);
687
687
  * // Returns: true
@@ -710,7 +710,7 @@ declare module "util" {
710
710
  * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
711
711
  *
712
712
  * ```js
713
- * const util = require('util');
713
+ * import util from 'node:util';
714
714
  *
715
715
  * util.isString('');
716
716
  * // Returns: true
@@ -729,7 +729,7 @@ declare module "util" {
729
729
  * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
730
730
  *
731
731
  * ```js
732
- * const util = require('util');
732
+ * import util from 'node:util';
733
733
  *
734
734
  * util.isSymbol(5);
735
735
  * // Returns: false
@@ -746,7 +746,7 @@ declare module "util" {
746
746
  * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
747
747
  *
748
748
  * ```js
749
- * const util = require('util');
749
+ * import util from 'node:util';
750
750
  *
751
751
  * const foo = undefined;
752
752
  * util.isUndefined(5);
@@ -765,7 +765,7 @@ declare module "util" {
765
765
  * such a way that it is marked as deprecated.
766
766
  *
767
767
  * ```js
768
- * const util = require('util');
768
+ * import util from 'node:util';
769
769
  *
770
770
  * exports.obsoleteFunction = util.deprecate(() => {
771
771
  * // Do something here.
@@ -781,7 +781,7 @@ declare module "util" {
781
781
  * the warning will be emitted only once for that `code`.
782
782
  *
783
783
  * ```js
784
- * const util = require('util');
784
+ * import util from 'node:util';
785
785
  *
786
786
  * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
787
787
  * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
@@ -835,7 +835,7 @@ declare module "util" {
835
835
  * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value.
836
836
  *
837
837
  * ```js
838
- * const util = require('util');
838
+ * import util from 'node:util';
839
839
  *
840
840
  * async function fn() {
841
841
  * return 'hello world';
@@ -961,8 +961,8 @@ declare module "util" {
961
961
  * that returns promises.
962
962
  *
963
963
  * ```js
964
- * const util = require('util');
965
- * const fs = require('fs');
964
+ * import util from 'node:util';
965
+ * import fs from 'node:fs';
966
966
  *
967
967
  * const stat = util.promisify(fs.stat);
968
968
  * stat('.').then((stats) => {
@@ -975,8 +975,8 @@ declare module "util" {
975
975
  * Or, equivalently using `async function`s:
976
976
  *
977
977
  * ```js
978
- * const util = require('util');
979
- * const fs = require('fs');
978
+ * import util from 'node:util';
979
+ * import fs from 'node:fs';
980
980
  *
981
981
  * const stat = util.promisify(fs.stat);
982
982
  *
@@ -997,7 +997,7 @@ declare module "util" {
997
997
  * work as expected unless handled specially:
998
998
  *
999
999
  * ```js
1000
- * const util = require('util');
1000
+ * import util from 'node:util';
1001
1001
  *
1002
1002
  * class Foo {
1003
1003
  * constructor() {
@@ -1166,7 +1166,7 @@ declare module "util" {
1166
1166
  import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
1167
1167
  global {
1168
1168
  /**
1169
- * `TextDecoder` class is a global reference for `require('util').TextDecoder`
1169
+ * `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
1170
1170
  * https://nodejs.org/api/globals.html#textdecoder
1171
1171
  * @since v11.0.0
1172
1172
  */
@@ -1177,7 +1177,7 @@ declare module "util" {
1177
1177
  : typeof _TextDecoder;
1178
1178
 
1179
1179
  /**
1180
- * `TextEncoder` class is a global reference for `require('util').TextEncoder`
1180
+ * `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
1181
1181
  * https://nodejs.org/api/globals.html#textencoder
1182
1182
  * @since v11.0.0
1183
1183
  */
node v16.18/v8.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
3
3
  *
4
4
  * ```js
5
- * const v8 = require('node:v8');
5
+ * import v8 from 'node:v8';
6
6
  * ```
7
7
  * @see [source](https://github.com/nodejs/node/blob/v16.20.2/lib/v8.js)
8
8
  */
@@ -164,7 +164,7 @@ declare module "v8" {
164
164
  *
165
165
  * ```js
166
166
  * // Print GC events to stdout for one minute.
167
- * const v8 = require('node:v8');
167
+ * import v8 from 'node:v8';
168
168
  * v8.setFlagsFromString('--trace_gc');
169
169
  * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
170
170
  * ```
@@ -187,7 +187,7 @@ declare module "v8" {
187
187
  *
188
188
  * ```js
189
189
  * // Print heap snapshot to the console
190
- * const v8 = require('node:v8');
190
+ * import v8 from 'node:v8';
191
191
  * const stream = v8.getHeapSnapshot();
192
192
  * stream.pipe(process.stdout);
193
193
  * ```
@@ -212,12 +212,12 @@ declare module "v8" {
212
212
  * for a duration depending on the heap size.
213
213
  *
214
214
  * ```js
215
- * const { writeHeapSnapshot } = require('node:v8');
216
- * const {
215
+ * import { writeHeapSnapshot } from 'node:v8';
216
+ * import {
217
217
  * Worker,
218
218
  * isMainThread,
219
219
  * parentPort,
220
- * } = require('node:worker_threads');
220
+ * } from 'node:worker_threads';
221
221
  *
222
222
  * if (isMainThread) {
223
223
  * const worker = new Worker(__filename);
@@ -554,12 +554,12 @@ declare module "v8" {
554
554
  * ```js
555
555
  * 'use strict';
556
556
  *
557
- * const fs = require('node:fs');
558
- * const zlib = require('node:zlib');
559
- * const path = require('node:path');
560
- * const assert = require('node:assert');
557
+ * import fs from 'node:fs';
558
+ * import zlib from 'node:zlib';
559
+ * import path from 'node:path';
560
+ * import assert from 'node:assert';
561
561
  *
562
- * const v8 = require('node:v8');
562
+ * import v8 from 'node:v8';
563
563
  *
564
564
  * class BookShelf {
565
565
  * storage = new Map();
node v16.18/vm.d.ts CHANGED
@@ -15,7 +15,7 @@
15
15
  * code are reflected in the context object.
16
16
  *
17
17
  * ```js
18
- * const vm = require('vm');
18
+ * import vm from 'node:vm';
19
19
  *
20
20
  * const x = 1;
21
21
  *
@@ -166,7 +166,7 @@ declare module "vm" {
166
166
  * The globals are contained in the `context` object.
167
167
  *
168
168
  * ```js
169
- * const vm = require('vm');
169
+ * import vm from 'node:vm';
170
170
  *
171
171
  * const context = {
172
172
  * animal: 'cat',
@@ -202,7 +202,7 @@ declare module "vm" {
202
202
  * contained within each individual `context`.
203
203
  *
204
204
  * ```js
205
- * const vm = require('vm');
205
+ * import vm from 'node:vm';
206
206
  *
207
207
  * const script = new vm.Script('globalVar = "set"');
208
208
  *
@@ -227,7 +227,7 @@ declare module "vm" {
227
227
  * executes that code multiple times:
228
228
  *
229
229
  * ```js
230
- * const vm = require('vm');
230
+ * import vm from 'node:vm';
231
231
  *
232
232
  * global.globalVar = 0;
233
233
  *
@@ -280,7 +280,7 @@ declare module "vm" {
280
280
  * will remain unchanged.
281
281
  *
282
282
  * ```js
283
- * const vm = require('vm');
283
+ * import vm from 'node:vm';
284
284
  *
285
285
  * global.globalVar = 3;
286
286
  *
@@ -327,7 +327,7 @@ declare module "vm" {
327
327
  * The following example compiles and executes different scripts using a single `contextified` object:
328
328
  *
329
329
  * ```js
330
- * const vm = require('vm');
330
+ * import vm from 'node:vm';
331
331
  *
332
332
  * const contextObject = { globalVar: 1 };
333
333
  * vm.createContext(contextObject);
@@ -356,7 +356,7 @@ declare module "vm" {
356
356
  * variable and sets a new one. These globals are contained in the `contextObject`.
357
357
  *
358
358
  * ```js
359
- * const vm = require('vm');
359
+ * import vm from 'node:vm';
360
360
  *
361
361
  * const contextObject = {
362
362
  * animal: 'cat',
@@ -384,7 +384,7 @@ declare module "vm" {
384
384
  * the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
385
385
  *
386
386
  * ```js
387
- * const vm = require('vm');
387
+ * import vm from 'node:vm';
388
388
  * let localVar = 'initial value';
389
389
  *
390
390
  * const vmResult = vm.runInThisContext('localVar = "vm";');
@@ -411,12 +411,11 @@ declare module "vm" {
411
411
  *
412
412
  * ```js
413
413
  * 'use strict';
414
- * const vm = require('vm');
414
+ * import vm from 'node:vm';
415
415
  *
416
416
  * const code = `
417
417
  * ((require) => {
418
- * const http = require('http');
419
- *
418
+ * const http = require('node:http');
420
419
  * http.createServer((request, response) => {
421
420
  * response.writeHead(200, { 'Content-Type': 'text/plain' });
422
421
  * response.end('Hello World\\n');
@@ -458,7 +457,7 @@ declare module "vm" {
458
457
  * the memory occupied by each heap space in the current V8 instance.
459
458
  *
460
459
  * ```js
461
- * const vm = require('vm');
460
+ * import vm from 'node:vm';
462
461
  * // Measure the memory used by the main context.
463
462
  * vm.measureMemory({ mode: 'summary' })
464
463
  * // This is the same as vm.measureMemory()
@@ -3,7 +3,7 @@
3
3
  * in parallel. To access it:
4
4
  *
5
5
  * ```js
6
- * const worker = require('worker_threads');
6
+ * import worker from 'node:worker_threads';
7
7
  * ```
8
8
  *
9
9
  * Workers (threads) are useful for performing CPU-intensive JavaScript operations.
@@ -14,9 +14,10 @@
14
14
  * so by transferring `ArrayBuffer` instances or sharing `SharedArrayBuffer`instances.
15
15
  *
16
16
  * ```js
17
- * const {
17
+ * import {
18
18
  * Worker, isMainThread, parentPort, workerData
19
- * } = require('worker_threads');
19
+ * } from 'node:worker_threads';
20
+ * import { parse } from 'some-js-parsing-library';
20
21
  *
21
22
  * if (isMainThread) {
22
23
  * module.exports = function parseJSAsync(script) {
@@ -33,7 +34,6 @@
33
34
  * });
34
35
  * };
35
36
  * } else {
36
- * const { parse } = require('some-js-parsing-library');
37
37
  * const script = workerData;
38
38
  * parentPort.postMessage(parse(script));
39
39
  * }
@@ -72,7 +72,7 @@ declare module "worker_threads" {
72
72
  * The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
73
73
  *
74
74
  * ```js
75
- * const { MessageChannel } = require('worker_threads');
75
+ * import { MessageChannel } from 'node:worker_threads';
76
76
  *
77
77
  * const { port1, port2 } = new MessageChannel();
78
78
  * port1.on('message', (message) => console.log('received', message));
@@ -121,7 +121,7 @@ declare module "worker_threads" {
121
121
  * * `value` may not contain native (C++-backed) objects other than:
122
122
  *
123
123
  * ```js
124
- * const { MessageChannel } = require('worker_threads');
124
+ * import { MessageChannel } from 'node:worker_threads';
125
125
  * const { port1, port2 } = new MessageChannel();
126
126
  *
127
127
  * port1.on('message', (message) => console.log(message));
@@ -143,7 +143,7 @@ declare module "worker_threads" {
143
143
  * `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved.
144
144
  *
145
145
  * ```js
146
- * const { MessageChannel } = require('worker_threads');
146
+ * import { MessageChannel } from 'node:worker_threads';
147
147
  * const { port1, port2 } = new MessageChannel();
148
148
  *
149
149
  * port1.on('message', (message) => console.log(message));
@@ -292,8 +292,8 @@ declare module "worker_threads" {
292
292
  * Notable differences inside a Worker environment are:
293
293
  *
294
294
  * * The `process.stdin`, `process.stdout` and `process.stderr` may be redirected by the parent thread.
295
- * * The `require('worker_threads').isMainThread` property is set to `false`.
296
- * * The `require('worker_threads').parentPort` message port is available.
295
+ * * The `import { isMainThread } from 'node:worker_threads'` property is set to `false`.
296
+ * * The `import { parentPort } from 'node:worker_threads'` message port is available.
297
297
  * * `process.exit()` does not stop the whole program, just the single thread,
298
298
  * and `process.abort()` is not available.
299
299
  * * `process.chdir()` and `process` methods that set group or user ids
@@ -327,10 +327,10 @@ declare module "worker_threads" {
327
327
  * the thread barrier.
328
328
  *
329
329
  * ```js
330
- * const assert = require('assert');
331
- * const {
330
+ * import assert from 'node:assert';
331
+ * import {
332
332
  * Worker, MessageChannel, MessagePort, isMainThread, parentPort
333
- * } = require('worker_threads');
333
+ * } from 'node:worker_threads';
334
334
  * if (isMainThread) {
335
335
  * const worker = new Worker(__filename);
336
336
  * const subChannel = new MessageChannel();
@@ -370,7 +370,7 @@ declare module "worker_threads" {
370
370
  readonly stderr: Readable;
371
371
  /**
372
372
  * An integer identifier for the referenced thread. Inside the worker thread,
373
- * it is available as `require('worker_threads').threadId`.
373
+ * it is available as `import { threadId } from 'node:worker_threads'`.
374
374
  * This value is unique for each `Worker` instance inside a single process.
375
375
  * @since v10.5.0
376
376
  */
@@ -488,11 +488,11 @@ declare module "worker_threads" {
488
488
  * ```js
489
489
  * 'use strict';
490
490
  *
491
- * const {
491
+ * import {
492
492
  * isMainThread,
493
493
  * BroadcastChannel,
494
494
  * Worker
495
- * } = require('worker_threads');
495
+ * } from 'node:worker_threads';
496
496
  *
497
497
  * const bc = new BroadcastChannel('hello');
498
498
  *
@@ -547,7 +547,7 @@ declare module "worker_threads" {
547
547
  * This operation cannot be undone.
548
548
  *
549
549
  * ```js
550
- * const { MessageChannel, markAsUntransferable } = require('worker_threads');
550
+ * import { MessageChannel, markAsUntransferable } from 'node:worker_threads';
551
551
  *
552
552
  * const pooledBuffer = new ArrayBuffer(8);
553
553
  * const typedArray1 = new Uint8Array(pooledBuffer);
@@ -592,7 +592,7 @@ declare module "worker_threads" {
592
592
  * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue.
593
593
  *
594
594
  * ```js
595
- * const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
595
+ * import { MessageChannel, receiveMessageOnPort } from 'node:worker_threads';
596
596
  * const { port1, port2 } = new MessageChannel();
597
597
  * port1.postMessage({ hello: 'world' });
598
598
  *
@@ -618,12 +618,12 @@ declare module "worker_threads" {
618
618
  * automatically.
619
619
  *
620
620
  * ```js
621
- * const {
621
+ * import {
622
622
  * Worker,
623
623
  * isMainThread,
624
624
  * setEnvironmentData,
625
625
  * getEnvironmentData,
626
- * } = require('worker_threads');
626
+ * } from 'node:worker_threads';
627
627
  *
628
628
  * if (isMainThread) {
629
629
  * setEnvironmentData('Hello', 'World!');
node v16.18/zlib.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * To access it:
6
6
  *
7
7
  * ```js
8
- * const zlib = require('zlib');
8
+ * import zlib from 'node:zlib';
9
9
  * ```
10
10
  *
11
11
  * Compression and decompression are built around the Node.js `Streams API`.
@@ -15,12 +15,12 @@
15
15
  * stream:
16
16
  *
17
17
  * ```js
18
- * const { createGzip } = require('zlib');
19
- * const { pipeline } = require('stream');
20
- * const {
18
+ * import { createGzip } from 'node:zlib';
19
+ * import { pipeline } from 'node:stream';
20
+ * import {
21
21
  * createReadStream,
22
22
  * createWriteStream
23
- * } = require('fs');
23
+ * } from 'node:fs';
24
24
  *
25
25
  * const gzip = createGzip();
26
26
  * const source = createReadStream('input.txt');
@@ -35,7 +35,7 @@
35
35
  *
36
36
  * // Or, Promisified
37
37
  *
38
- * const { promisify } = require('util');
38
+ * import { promisify } from 'node:util';
39
39
  * const pipe = promisify(pipeline);
40
40
  *
41
41
  * async function do_gzip(input, output) {
@@ -55,7 +55,7 @@
55
55
  * It is also possible to compress or decompress data in a single step:
56
56
  *
57
57
  * ```js
58
- * const { deflate, unzip } = require('zlib');
58
+ * import { deflate, unzip } from 'node:zlib';
59
59
  *
60
60
  * const input = '.................................';
61
61
  * deflate(input, (err, buffer) => {
@@ -77,7 +77,7 @@
77
77
  *
78
78
  * // Or, Promisified
79
79
  *
80
- * const { promisify } = require('util');
80
+ * import { promisify } from 'node:util';
81
81
  * const do_unzip = promisify(unzip);
82
82
  *
83
83
  * do_unzip(buffer)