@types/node 20.16.8 → 20.16.9

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.
@@ -3,7 +3,7 @@
3
3
  * JavaScript in parallel. To access it:
4
4
  *
5
5
  * ```js
6
- * const worker = require('node: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('node: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('node: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('node: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('node: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));
@@ -298,8 +298,8 @@ declare module "worker_threads" {
298
298
  * Notable differences inside a Worker environment are:
299
299
  *
300
300
  * * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
301
- * * The `require('node:worker_threads').isMainThread` property is set to `false`.
302
- * * The `require('node:worker_threads').parentPort` message port is available.
301
+ * * The `import { isMainThread } from 'node:worker_threads'` property is set to `false`.
302
+ * * The `import { parentPort } from 'node:worker_threads'` message port is available.
303
303
  * * `process.exit()` does not stop the whole program, just the single thread,
304
304
  * and `process.abort()` is not available.
305
305
  * * `process.chdir()` and `process` methods that set group or user ids
@@ -334,10 +334,10 @@ declare module "worker_threads" {
334
334
  * the thread barrier.
335
335
  *
336
336
  * ```js
337
- * const assert = require('node:assert');
338
- * const {
337
+ * import assert from 'node:assert';
338
+ * import {
339
339
  * Worker, MessageChannel, MessagePort, isMainThread, parentPort,
340
- * } = require('node:worker_threads');
340
+ * } from 'node:worker_threads';
341
341
  * if (isMainThread) {
342
342
  * const worker = new Worker(__filename);
343
343
  * const subChannel = new MessageChannel();
@@ -377,7 +377,7 @@ declare module "worker_threads" {
377
377
  readonly stderr: Readable;
378
378
  /**
379
379
  * An integer identifier for the referenced thread. Inside the worker thread,
380
- * it is available as `require('node:worker_threads').threadId`.
380
+ * it is available as `import { threadId } from 'node:node:worker_threads'`.
381
381
  * This value is unique for each `Worker` instance inside a single process.
382
382
  * @since v10.5.0
383
383
  */
@@ -495,11 +495,11 @@ declare module "worker_threads" {
495
495
  * ```js
496
496
  * 'use strict';
497
497
  *
498
- * const {
498
+ * import {
499
499
  * isMainThread,
500
500
  * BroadcastChannel,
501
501
  * Worker,
502
- * } = require('node:worker_threads');
502
+ * } from 'node:worker_threads';
503
503
  *
504
504
  * const bc = new BroadcastChannel('hello');
505
505
  *
@@ -553,7 +553,7 @@ declare module "worker_threads" {
553
553
  * This operation cannot be undone.
554
554
  *
555
555
  * ```js
556
- * const { MessageChannel, markAsUntransferable } = require('node:worker_threads');
556
+ * import { MessageChannel, markAsUntransferable } from 'node:worker_threads';
557
557
  *
558
558
  * const pooledBuffer = new ArrayBuffer(8);
559
559
  * const typedArray1 = new Uint8Array(pooledBuffer);
@@ -598,7 +598,7 @@ declare module "worker_threads" {
598
598
  * that contains the message payload, corresponding to the oldest message in the `MessagePort`'s queue.
599
599
  *
600
600
  * ```js
601
- * const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads');
601
+ * import { MessageChannel, receiveMessageOnPort } from 'node:worker_threads';
602
602
  * const { port1, port2 } = new MessageChannel();
603
603
  * port1.postMessage({ hello: 'world' });
604
604
  *
@@ -624,12 +624,12 @@ declare module "worker_threads" {
624
624
  * automatically.
625
625
  *
626
626
  * ```js
627
- * const {
627
+ * import {
628
628
  * Worker,
629
629
  * isMainThread,
630
630
  * setEnvironmentData,
631
631
  * getEnvironmentData,
632
- * } = require('node:worker_threads');
632
+ * } from 'node:worker_threads';
633
633
  *
634
634
  * if (isMainThread) {
635
635
  * setEnvironmentData('Hello', 'World!');
@@ -658,7 +658,7 @@ declare module "worker_threads" {
658
658
  } from "worker_threads";
659
659
  global {
660
660
  /**
661
- * `BroadcastChannel` class is a global reference for `require('worker_threads').BroadcastChannel`
661
+ * `BroadcastChannel` class is a global reference for `import { BroadcastChannel } from 'node:worker_threads'`
662
662
  * https://nodejs.org/api/globals.html#broadcastchannel
663
663
  * @since v18.0.0
664
664
  */
@@ -668,7 +668,7 @@ declare module "worker_threads" {
668
668
  } ? T
669
669
  : typeof _BroadcastChannel;
670
670
  /**
671
- * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
671
+ * `MessageChannel` class is a global reference for `import { MessageChannel } from 'node:worker_threads'`
672
672
  * https://nodejs.org/api/globals.html#messagechannel
673
673
  * @since v15.0.0
674
674
  */
@@ -678,7 +678,7 @@ declare module "worker_threads" {
678
678
  } ? T
679
679
  : typeof _MessageChannel;
680
680
  /**
681
- * `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
681
+ * `MessagePort` class is a global reference for `import { MessagePort } from 'node:worker_threads'`
682
682
  * https://nodejs.org/api/globals.html#messageport
683
683
  * @since v15.0.0
684
684
  */
node v20.16/zlib.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * To access it:
6
6
  *
7
7
  * ```js
8
- * const zlib = require('node:zlib');
8
+ * import zlib from 'node:zlib';
9
9
  * ```
10
10
  *
11
11
  * Compression and decompression are built around the Node.js
@@ -16,12 +16,12 @@
16
16
  * stream:
17
17
  *
18
18
  * ```js
19
- * const { createGzip } = require('node:zlib');
20
- * const { pipeline } = require('node:stream');
21
- * const {
19
+ * import { createGzip } from 'node:zlib';
20
+ * import { pipeline } from 'node:stream';
21
+ * import {
22
22
  * createReadStream,
23
23
  * createWriteStream,
24
- * } = require('node:fs');
24
+ * } from 'node:fs';
25
25
  *
26
26
  * const gzip = createGzip();
27
27
  * const source = createReadStream('input.txt');
@@ -36,7 +36,7 @@
36
36
  *
37
37
  * // Or, Promisified
38
38
  *
39
- * const { promisify } = require('node:util');
39
+ * import { promisify } from 'node:util';
40
40
  * const pipe = promisify(pipeline);
41
41
  *
42
42
  * async function do_gzip(input, output) {
@@ -56,7 +56,7 @@
56
56
  * It is also possible to compress or decompress data in a single step:
57
57
  *
58
58
  * ```js
59
- * const { deflate, unzip } = require('node:zlib');
59
+ * import { deflate, unzip } from 'node:zlib';
60
60
  *
61
61
  * const input = '.................................';
62
62
  * deflate(input, (err, buffer) => {
@@ -78,7 +78,7 @@
78
78
  *
79
79
  * // Or, Promisified
80
80
  *
81
- * const { promisify } = require('node:util');
81
+ * import { promisify } from 'node:util';
82
82
  * const do_unzip = promisify(unzip);
83
83
  *
84
84
  * do_unzip(buffer)