@types/node 16.18.109 → 16.18.111

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
  * 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)