@types/node 18.19.51 → 18.19.53
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.
- node v18.19/README.md +1 -1
- node v18.19/buffer.d.ts +15 -8
- node v18.19/child_process.d.ts +35 -30
- node v18.19/cluster.d.ts +1 -1
- node v18.19/console.d.ts +2 -2
- node v18.19/crypto.d.ts +1 -1
- node v18.19/dns/promises.d.ts +6 -5
- node v18.19/dns.d.ts +5 -5
- node v18.19/domain.d.ts +2 -2
- node v18.19/events.d.ts +13 -13
- node v18.19/fs/promises.d.ts +2 -2
- node v18.19/fs.d.ts +1 -1
- node v18.19/http.d.ts +4 -4
- node v18.19/http2.d.ts +24 -24
- node v18.19/https.d.ts +9 -9
- node v18.19/inspector.d.ts +1 -1
- node v18.19/module.d.ts +3 -3
- node v18.19/net.d.ts +2 -2
- node v18.19/os.d.ts +1 -1
- node v18.19/package.json +2 -2
- node v18.19/path.d.ts +1 -1
- node v18.19/perf_hooks.d.ts +11 -11
- node v18.19/punycode.d.ts +1 -1
- node v18.19/querystring.d.ts +1 -1
- node v18.19/readline/promises.d.ts +1 -1
- node v18.19/readline.d.ts +18 -18
- node v18.19/repl.d.ts +4 -4
- node v18.19/stream.d.ts +21 -21
- node v18.19/string_decoder.d.ts +3 -3
- node v18.19/timers/promises.d.ts +1 -1
- node v18.19/timers.d.ts +1 -1
- node v18.19/tls.d.ts +5 -5
- node v18.19/trace_events.d.ts +3 -3
- node v18.19/tty.d.ts +1 -1
- node v18.19/url.d.ts +7 -7
- node v18.19/util.d.ts +41 -41
- node v18.19/v8.d.ts +12 -12
- node v18.19/vm.d.ts +11 -12
- node v18.19/worker_threads.d.ts +22 -22
- node v18.19/zlib.d.ts +8 -8
node v18.19/stream.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* To access the `stream` module:
|
|
10
10
|
*
|
|
11
11
|
* ```js
|
|
12
|
-
*
|
|
12
|
+
* import stream from 'node:stream';
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
15
|
* The `stream` module is useful for creating new types of stream instances. It is
|
|
@@ -326,7 +326,7 @@ declare module "stream" {
|
|
|
326
326
|
* the method does nothing.
|
|
327
327
|
*
|
|
328
328
|
* ```js
|
|
329
|
-
*
|
|
329
|
+
* import fs from 'node:fs';
|
|
330
330
|
* const readable = getReadableStreamSomehow();
|
|
331
331
|
* const writable = fs.createWriteStream('file.txt');
|
|
332
332
|
* // All the data from readable goes into 'file.txt',
|
|
@@ -364,7 +364,7 @@ declare module "stream" {
|
|
|
364
364
|
* // Pull off a header delimited by \n\n.
|
|
365
365
|
* // Use unshift() if we get too much.
|
|
366
366
|
* // Call the callback with (error, header, stream).
|
|
367
|
-
*
|
|
367
|
+
* import { StringDecoder } from 'node:string_decoder';
|
|
368
368
|
* function parseHeader(stream, callback) {
|
|
369
369
|
* stream.on('error', callback);
|
|
370
370
|
* stream.on('readable', onReadable);
|
|
@@ -422,8 +422,8 @@ declare module "stream" {
|
|
|
422
422
|
* libraries.
|
|
423
423
|
*
|
|
424
424
|
* ```js
|
|
425
|
-
*
|
|
426
|
-
*
|
|
425
|
+
* import { OldReader } from './old-api-module.js';
|
|
426
|
+
* import { Readable } from 'node:stream';
|
|
427
427
|
* const oreader = new OldReader();
|
|
428
428
|
* const myReader = new Readable().wrap(oreader);
|
|
429
429
|
*
|
|
@@ -865,7 +865,7 @@ declare module "stream" {
|
|
|
865
865
|
*
|
|
866
866
|
* ```js
|
|
867
867
|
* // Write 'hello, ' and then end with 'world!'.
|
|
868
|
-
*
|
|
868
|
+
* import fs from 'node:fs';
|
|
869
869
|
* const file = fs.createWriteStream('example.txt');
|
|
870
870
|
* file.write('hello, ');
|
|
871
871
|
* file.end('world!');
|
|
@@ -1261,7 +1261,7 @@ declare module "stream" {
|
|
|
1261
1261
|
* Calling `abort` on the `AbortController` corresponding to the passed`AbortSignal` will behave the same way as calling `.destroy(new AbortError())`on the stream.
|
|
1262
1262
|
*
|
|
1263
1263
|
* ```js
|
|
1264
|
-
*
|
|
1264
|
+
* import fs from 'node:fs';
|
|
1265
1265
|
*
|
|
1266
1266
|
* const controller = new AbortController();
|
|
1267
1267
|
* const read = addAbortSignal(
|
|
@@ -1324,7 +1324,7 @@ declare module "stream" {
|
|
|
1324
1324
|
* or has experienced an error or a premature close event.
|
|
1325
1325
|
*
|
|
1326
1326
|
* ```js
|
|
1327
|
-
*
|
|
1327
|
+
* import { finished } from 'node:stream';
|
|
1328
1328
|
*
|
|
1329
1329
|
* const rs = fs.createReadStream('archive.tar');
|
|
1330
1330
|
*
|
|
@@ -1345,7 +1345,7 @@ declare module "stream" {
|
|
|
1345
1345
|
* The `finished` API provides promise version:
|
|
1346
1346
|
*
|
|
1347
1347
|
* ```js
|
|
1348
|
-
*
|
|
1348
|
+
* import { finished } from 'node:stream/promises';
|
|
1349
1349
|
*
|
|
1350
1350
|
* const rs = fs.createReadStream('archive.tar');
|
|
1351
1351
|
*
|
|
@@ -1421,9 +1421,9 @@ declare module "stream" {
|
|
|
1421
1421
|
* properly cleaning up and provide a callback when the pipeline is complete.
|
|
1422
1422
|
*
|
|
1423
1423
|
* ```js
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1424
|
+
* import { pipeline } from 'node:stream';
|
|
1425
|
+
* import fs from 'node:fs';
|
|
1426
|
+
* import zlib from 'node:zlib';
|
|
1427
1427
|
*
|
|
1428
1428
|
* // Use the pipeline API to easily pipe a series of streams
|
|
1429
1429
|
* // together and get notified when the pipeline is fully done.
|
|
@@ -1449,7 +1449,7 @@ declare module "stream" {
|
|
|
1449
1449
|
* an`AbortError`.
|
|
1450
1450
|
*
|
|
1451
1451
|
* ```js
|
|
1452
|
-
*
|
|
1452
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1453
1453
|
*
|
|
1454
1454
|
* async function run() {
|
|
1455
1455
|
* await pipeline(
|
|
@@ -1467,7 +1467,7 @@ declare module "stream" {
|
|
|
1467
1467
|
* as the last argument:
|
|
1468
1468
|
*
|
|
1469
1469
|
* ```js
|
|
1470
|
-
*
|
|
1470
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1471
1471
|
*
|
|
1472
1472
|
* async function run() {
|
|
1473
1473
|
* const ac = new AbortController();
|
|
@@ -1488,8 +1488,8 @@ declare module "stream" {
|
|
|
1488
1488
|
* The `pipeline` API also supports async generators:
|
|
1489
1489
|
*
|
|
1490
1490
|
* ```js
|
|
1491
|
-
*
|
|
1492
|
-
*
|
|
1491
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1492
|
+
* import fs from 'node:fs';
|
|
1493
1493
|
*
|
|
1494
1494
|
* async function run() {
|
|
1495
1495
|
* await pipeline(
|
|
@@ -1513,8 +1513,8 @@ declare module "stream" {
|
|
|
1513
1513
|
* pipeline (i.e. first argument) or the pipeline will never complete.
|
|
1514
1514
|
*
|
|
1515
1515
|
* ```js
|
|
1516
|
-
*
|
|
1517
|
-
*
|
|
1516
|
+
* import { pipeline } from 'node:stream/promises';
|
|
1517
|
+
* import fs from 'node:fs';
|
|
1518
1518
|
*
|
|
1519
1519
|
* async function run() {
|
|
1520
1520
|
* await pipeline(
|
|
@@ -1547,9 +1547,9 @@ declare module "stream" {
|
|
|
1547
1547
|
* See the example below:
|
|
1548
1548
|
*
|
|
1549
1549
|
* ```js
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1550
|
+
* import fs from 'node:fs';
|
|
1551
|
+
* import http from 'node:http';
|
|
1552
|
+
* import { pipeline } from 'node:stream';
|
|
1553
1553
|
*
|
|
1554
1554
|
* const server = http.createServer((req, res) => {
|
|
1555
1555
|
* const fileStream = fs.createReadStream('./fileNotExist.txt');
|
node v18.19/string_decoder.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* characters. It can be accessed using:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
|
-
*
|
|
7
|
+
* import { StringDecoder } from 'node:string_decoder';
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
10
10
|
* The following example shows the basic use of the `StringDecoder` class.
|
|
11
11
|
*
|
|
12
12
|
* ```js
|
|
13
|
-
*
|
|
13
|
+
* import { StringDecoder } from 'node:string_decoder';
|
|
14
14
|
* const decoder = new StringDecoder('utf8');
|
|
15
15
|
*
|
|
16
16
|
* const cent = Buffer.from([0xC2, 0xA2]);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* symbol (`€`) are written over three separate operations:
|
|
30
30
|
*
|
|
31
31
|
* ```js
|
|
32
|
-
*
|
|
32
|
+
* import { StringDecoder } from 'node:string_decoder';
|
|
33
33
|
* const decoder = new StringDecoder('utf8');
|
|
34
34
|
*
|
|
35
35
|
* decoder.write(Buffer.from([0xE2]));
|
node v18.19/timers/promises.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `timers/promises` API provides an alternative set of timer functions
|
|
3
|
-
* that return `Promise` objects. The API is accessible via`
|
|
3
|
+
* that return `Promise` objects. The API is accessible via `import timersPromises from 'node:timers/promises'`.
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
6
|
* import {
|
node v18.19/timers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `timer` module exposes a global API for scheduling functions to
|
|
3
3
|
* be called at some future period of time. Because the timer functions are
|
|
4
|
-
* globals, there is no need to
|
|
4
|
+
* globals, there is no need to import `node:timers` to use the API.
|
|
5
5
|
*
|
|
6
6
|
* The timer functions within Node.js implement a similar API as the timers API
|
|
7
7
|
* provided by Web Browsers but use a different internal implementation that is
|
node v18.19/tls.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The module can be accessed using:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
|
-
*
|
|
7
|
+
* import tls from 'node:tls';
|
|
8
8
|
* ```
|
|
9
9
|
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/tls.js)
|
|
10
10
|
*/
|
|
@@ -1000,8 +1000,8 @@ declare module "tls" {
|
|
|
1000
1000
|
* The following illustrates a simple echo server:
|
|
1001
1001
|
*
|
|
1002
1002
|
* ```js
|
|
1003
|
-
*
|
|
1004
|
-
*
|
|
1003
|
+
* import tls from 'node:tls';
|
|
1004
|
+
* import fs from 'node:fs';
|
|
1005
1005
|
*
|
|
1006
1006
|
* const options = {
|
|
1007
1007
|
* key: fs.readFileSync('server-key.pem'),
|
|
@@ -1046,8 +1046,8 @@ declare module "tls" {
|
|
|
1046
1046
|
*
|
|
1047
1047
|
* ```js
|
|
1048
1048
|
* // Assumes an echo server that is listening on port 8000.
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1049
|
+
* import tls from 'node:tls';
|
|
1050
|
+
* import fs from 'node:fs';
|
|
1051
1051
|
*
|
|
1052
1052
|
* const options = {
|
|
1053
1053
|
* // Necessary only if the server requires client certificate authentication.
|
node v18.19/trace_events.d.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* Alternatively, trace events may be enabled using the `trace_events` module:
|
|
47
47
|
*
|
|
48
48
|
* ```js
|
|
49
|
-
*
|
|
49
|
+
* import trace_events from 'node:trace_events';
|
|
50
50
|
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
|
51
51
|
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
|
52
52
|
*
|
|
@@ -132,7 +132,7 @@ declare module "trace_events" {
|
|
|
132
132
|
* Creates and returns a `Tracing` object for the given set of `categories`.
|
|
133
133
|
*
|
|
134
134
|
* ```js
|
|
135
|
-
*
|
|
135
|
+
* import trace_events from 'node:trace_events';
|
|
136
136
|
* const categories = ['node.perf', 'node.async_hooks'];
|
|
137
137
|
* const tracing = trace_events.createTracing({ categories });
|
|
138
138
|
* tracing.enable();
|
|
@@ -152,7 +152,7 @@ declare module "trace_events" {
|
|
|
152
152
|
* Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console.
|
|
153
153
|
*
|
|
154
154
|
* ```js
|
|
155
|
-
*
|
|
155
|
+
* import trace_events from 'node:trace_events';
|
|
156
156
|
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
|
|
157
157
|
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
|
|
158
158
|
* const t3 = trace_events.createTracing({ categories: ['v8'] });
|
node v18.19/tty.d.ts
CHANGED
node v18.19/url.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare module "url" {
|
|
|
83
83
|
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
84
84
|
*
|
|
85
85
|
* ```js
|
|
86
|
-
*
|
|
86
|
+
* import url from 'node:url';
|
|
87
87
|
* url.format({
|
|
88
88
|
* protocol: 'https',
|
|
89
89
|
* hostname: 'example.com',
|
|
@@ -147,7 +147,7 @@ declare module "url" {
|
|
|
147
147
|
* The `url.format()` method returns a formatted URL string derived from `urlObject`.
|
|
148
148
|
*
|
|
149
149
|
* ```js
|
|
150
|
-
*
|
|
150
|
+
* import url from 'node:url';
|
|
151
151
|
* url.format({
|
|
152
152
|
* protocol: 'https',
|
|
153
153
|
* hostname: 'example.com',
|
|
@@ -212,7 +212,7 @@ declare module "url" {
|
|
|
212
212
|
* manner similar to that of a web browser resolving an anchor tag.
|
|
213
213
|
*
|
|
214
214
|
* ```js
|
|
215
|
-
*
|
|
215
|
+
* import url from 'node:url';
|
|
216
216
|
* url.resolve('/one/two/three', 'four'); // '/one/two/four'
|
|
217
217
|
* url.resolve('http://example.com/', '/one'); // 'http://example.com/one'
|
|
218
218
|
* url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
|
|
@@ -394,10 +394,10 @@ declare module "url" {
|
|
|
394
394
|
* Creates a `'blob:nodedata:...'` URL string that represents the given `Blob` object and can be used to retrieve the `Blob` later.
|
|
395
395
|
*
|
|
396
396
|
* ```js
|
|
397
|
-
*
|
|
397
|
+
* import {
|
|
398
398
|
* Blob,
|
|
399
399
|
* resolveObjectURL,
|
|
400
|
-
* }
|
|
400
|
+
* } from 'node:buffer';
|
|
401
401
|
*
|
|
402
402
|
* const blob = new Blob(['hello']);
|
|
403
403
|
* const id = URL.createObjectURL(blob);
|
|
@@ -928,7 +928,7 @@ declare module "url" {
|
|
|
928
928
|
URLSearchParams: typeof _URLSearchParams;
|
|
929
929
|
}
|
|
930
930
|
/**
|
|
931
|
-
* `URL` class is a global reference for `
|
|
931
|
+
* `URL` class is a global reference for `import { URL } from 'node:url'`
|
|
932
932
|
* https://nodejs.org/api/url.html#the-whatwg-url-api
|
|
933
933
|
* @since v10.0.0
|
|
934
934
|
*/
|
|
@@ -938,7 +938,7 @@ declare module "url" {
|
|
|
938
938
|
} ? T
|
|
939
939
|
: typeof _URL;
|
|
940
940
|
/**
|
|
941
|
-
* `URLSearchParams` class is a global reference for `
|
|
941
|
+
* `URLSearchParams` class is a global reference for `import { URLSearchParams } from 'node:url'`
|
|
942
942
|
* https://nodejs.org/api/url.html#class-urlsearchparams
|
|
943
943
|
* @since v10.0.0
|
|
944
944
|
*/
|
node v18.19/util.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* it:
|
|
5
5
|
*
|
|
6
6
|
* ```js
|
|
7
|
-
*
|
|
7
|
+
* import util from 'node:util';
|
|
8
8
|
* ```
|
|
9
9
|
* @see [source](https://github.com/nodejs/node/blob/v18.x/lib/util.js)
|
|
10
10
|
*/
|
|
@@ -200,7 +200,7 @@ declare module "util" {
|
|
|
200
200
|
* timestamp.
|
|
201
201
|
*
|
|
202
202
|
* ```js
|
|
203
|
-
*
|
|
203
|
+
* import util from 'node:util';
|
|
204
204
|
*
|
|
205
205
|
* util.log('Timestamped message.');
|
|
206
206
|
* ```
|
|
@@ -268,7 +268,7 @@ declare module "util" {
|
|
|
268
268
|
* Circular references point to their anchor by using a reference index:
|
|
269
269
|
*
|
|
270
270
|
* ```js
|
|
271
|
-
*
|
|
271
|
+
* import { inspect } from 'node:util';
|
|
272
272
|
*
|
|
273
273
|
* const obj = {};
|
|
274
274
|
* obj.a = [obj];
|
|
@@ -286,7 +286,7 @@ declare module "util" {
|
|
|
286
286
|
* The following example inspects all properties of the `util` object:
|
|
287
287
|
*
|
|
288
288
|
* ```js
|
|
289
|
-
*
|
|
289
|
+
* import util from 'node:util';
|
|
290
290
|
*
|
|
291
291
|
* console.log(util.inspect(util, { showHidden: true, depth: null }));
|
|
292
292
|
* ```
|
|
@@ -294,7 +294,7 @@ declare module "util" {
|
|
|
294
294
|
* The following example highlights the effect of the `compact` option:
|
|
295
295
|
*
|
|
296
296
|
* ```js
|
|
297
|
-
*
|
|
297
|
+
* import util from 'node:util';
|
|
298
298
|
*
|
|
299
299
|
* const o = {
|
|
300
300
|
* a: [1, 2, [[
|
|
@@ -351,7 +351,7 @@ declare module "util" {
|
|
|
351
351
|
* with no remaining strong references may be garbage collected at any time.
|
|
352
352
|
*
|
|
353
353
|
* ```js
|
|
354
|
-
*
|
|
354
|
+
* import { inspect } from 'node:util';
|
|
355
355
|
*
|
|
356
356
|
* const obj = { a: 1 };
|
|
357
357
|
* const obj2 = { b: 2 };
|
|
@@ -365,8 +365,8 @@ declare module "util" {
|
|
|
365
365
|
* impact the result of `util.inspect()`.
|
|
366
366
|
*
|
|
367
367
|
* ```js
|
|
368
|
-
*
|
|
369
|
-
*
|
|
368
|
+
* import { inspect } from 'node:util';
|
|
369
|
+
* import assert from 'node:assert';
|
|
370
370
|
*
|
|
371
371
|
* const o1 = {
|
|
372
372
|
* b: [2, 3, 1],
|
|
@@ -393,7 +393,7 @@ declare module "util" {
|
|
|
393
393
|
* numbers.
|
|
394
394
|
*
|
|
395
395
|
* ```js
|
|
396
|
-
*
|
|
396
|
+
* import { inspect } from 'node:util';
|
|
397
397
|
*
|
|
398
398
|
* const thousand = 1_000;
|
|
399
399
|
* const million = 1_000_000;
|
|
@@ -434,7 +434,7 @@ declare module "util" {
|
|
|
434
434
|
* Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
|
|
435
435
|
*
|
|
436
436
|
* ```js
|
|
437
|
-
*
|
|
437
|
+
* import util from 'node:util';
|
|
438
438
|
*
|
|
439
439
|
* util.isArray([]);
|
|
440
440
|
* // Returns: true
|
|
@@ -451,7 +451,7 @@ declare module "util" {
|
|
|
451
451
|
* Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
|
|
452
452
|
*
|
|
453
453
|
* ```js
|
|
454
|
-
*
|
|
454
|
+
* import util from 'node:util';
|
|
455
455
|
*
|
|
456
456
|
* util.isRegExp(/some regexp/);
|
|
457
457
|
* // Returns: true
|
|
@@ -468,7 +468,7 @@ declare module "util" {
|
|
|
468
468
|
* Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
|
|
469
469
|
*
|
|
470
470
|
* ```js
|
|
471
|
-
*
|
|
471
|
+
* import util from 'node:util';
|
|
472
472
|
*
|
|
473
473
|
* util.isDate(new Date());
|
|
474
474
|
* // Returns: true
|
|
@@ -485,7 +485,7 @@ declare module "util" {
|
|
|
485
485
|
* Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`.
|
|
486
486
|
*
|
|
487
487
|
* ```js
|
|
488
|
-
*
|
|
488
|
+
* import util from 'node:util';
|
|
489
489
|
*
|
|
490
490
|
* util.isError(new Error());
|
|
491
491
|
* // Returns: true
|
|
@@ -499,7 +499,7 @@ declare module "util" {
|
|
|
499
499
|
* possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`.
|
|
500
500
|
*
|
|
501
501
|
* ```js
|
|
502
|
-
*
|
|
502
|
+
* import util from 'node:util';
|
|
503
503
|
* const obj = { name: 'Error', message: 'an error occurred' };
|
|
504
504
|
*
|
|
505
505
|
* util.isError(obj);
|
|
@@ -524,8 +524,8 @@ declare module "util" {
|
|
|
524
524
|
* through the `constructor.super_` property.
|
|
525
525
|
*
|
|
526
526
|
* ```js
|
|
527
|
-
*
|
|
528
|
-
*
|
|
527
|
+
* import util from 'node:util';
|
|
528
|
+
* import EventEmitter from 'node:events';
|
|
529
529
|
*
|
|
530
530
|
* function MyStream() {
|
|
531
531
|
* EventEmitter.call(this);
|
|
@@ -551,7 +551,7 @@ declare module "util" {
|
|
|
551
551
|
* ES6 example using `class` and `extends`:
|
|
552
552
|
*
|
|
553
553
|
* ```js
|
|
554
|
-
*
|
|
554
|
+
* import EventEmitter from 'node:events';
|
|
555
555
|
*
|
|
556
556
|
* class MyStream extends EventEmitter {
|
|
557
557
|
* write(data) {
|
|
@@ -580,7 +580,7 @@ declare module "util" {
|
|
|
580
580
|
* environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
|
|
581
581
|
*
|
|
582
582
|
* ```js
|
|
583
|
-
*
|
|
583
|
+
* import util from 'node:util';
|
|
584
584
|
* const debuglog = util.debuglog('foo');
|
|
585
585
|
*
|
|
586
586
|
* debuglog('hello from foo [%d]', 123);
|
|
@@ -599,7 +599,7 @@ declare module "util" {
|
|
|
599
599
|
* The `section` supports wildcard also:
|
|
600
600
|
*
|
|
601
601
|
* ```js
|
|
602
|
-
*
|
|
602
|
+
* import util from 'node:util';
|
|
603
603
|
* const debuglog = util.debuglog('foo-bar');
|
|
604
604
|
*
|
|
605
605
|
* debuglog('hi there, it\'s foo-bar [%d]', 2333);
|
|
@@ -619,7 +619,7 @@ declare module "util" {
|
|
|
619
619
|
* unnecessary wrapping.
|
|
620
620
|
*
|
|
621
621
|
* ```js
|
|
622
|
-
*
|
|
622
|
+
* import util from 'node:util';
|
|
623
623
|
* let debuglog = util.debuglog('internals', (debug) => {
|
|
624
624
|
* // Replace with a logging function that optimizes out
|
|
625
625
|
* // testing if the section is enabled
|
|
@@ -637,7 +637,7 @@ declare module "util" {
|
|
|
637
637
|
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
|
|
638
638
|
*
|
|
639
639
|
* ```js
|
|
640
|
-
*
|
|
640
|
+
* import util from 'node:util';
|
|
641
641
|
*
|
|
642
642
|
* util.isBoolean(1);
|
|
643
643
|
* // Returns: false
|
|
@@ -654,7 +654,7 @@ declare module "util" {
|
|
|
654
654
|
* Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
|
|
655
655
|
*
|
|
656
656
|
* ```js
|
|
657
|
-
*
|
|
657
|
+
* import util from 'node:util';
|
|
658
658
|
*
|
|
659
659
|
* util.isBuffer({ length: 0 });
|
|
660
660
|
* // Returns: false
|
|
@@ -671,7 +671,7 @@ declare module "util" {
|
|
|
671
671
|
* Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`.
|
|
672
672
|
*
|
|
673
673
|
* ```js
|
|
674
|
-
*
|
|
674
|
+
* import util from 'node:util';
|
|
675
675
|
*
|
|
676
676
|
* function Foo() {}
|
|
677
677
|
* const Bar = () => {};
|
|
@@ -691,7 +691,7 @@ declare module "util" {
|
|
|
691
691
|
* Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
|
|
692
692
|
*
|
|
693
693
|
* ```js
|
|
694
|
-
*
|
|
694
|
+
* import util from 'node:util';
|
|
695
695
|
*
|
|
696
696
|
* util.isNull(0);
|
|
697
697
|
* // Returns: false
|
|
@@ -709,7 +709,7 @@ declare module "util" {
|
|
|
709
709
|
* returns `false`.
|
|
710
710
|
*
|
|
711
711
|
* ```js
|
|
712
|
-
*
|
|
712
|
+
* import util from 'node:util';
|
|
713
713
|
*
|
|
714
714
|
* util.isNullOrUndefined(0);
|
|
715
715
|
* // Returns: false
|
|
@@ -726,7 +726,7 @@ declare module "util" {
|
|
|
726
726
|
* Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
|
|
727
727
|
*
|
|
728
728
|
* ```js
|
|
729
|
-
*
|
|
729
|
+
* import util from 'node:util';
|
|
730
730
|
*
|
|
731
731
|
* util.isNumber(false);
|
|
732
732
|
* // Returns: false
|
|
@@ -746,7 +746,7 @@ declare module "util" {
|
|
|
746
746
|
* Otherwise, returns `false`.
|
|
747
747
|
*
|
|
748
748
|
* ```js
|
|
749
|
-
*
|
|
749
|
+
* import util from 'node:util';
|
|
750
750
|
*
|
|
751
751
|
* util.isObject(5);
|
|
752
752
|
* // Returns: false
|
|
@@ -765,7 +765,7 @@ declare module "util" {
|
|
|
765
765
|
* Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
|
|
766
766
|
*
|
|
767
767
|
* ```js
|
|
768
|
-
*
|
|
768
|
+
* import util from 'node:util';
|
|
769
769
|
*
|
|
770
770
|
* util.isPrimitive(5);
|
|
771
771
|
* // Returns: true
|
|
@@ -794,7 +794,7 @@ declare module "util" {
|
|
|
794
794
|
* Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
|
|
795
795
|
*
|
|
796
796
|
* ```js
|
|
797
|
-
*
|
|
797
|
+
* import util from 'node:util';
|
|
798
798
|
*
|
|
799
799
|
* util.isString('');
|
|
800
800
|
* // Returns: true
|
|
@@ -813,7 +813,7 @@ declare module "util" {
|
|
|
813
813
|
* Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
|
|
814
814
|
*
|
|
815
815
|
* ```js
|
|
816
|
-
*
|
|
816
|
+
* import util from 'node:util';
|
|
817
817
|
*
|
|
818
818
|
* util.isSymbol(5);
|
|
819
819
|
* // Returns: false
|
|
@@ -830,7 +830,7 @@ declare module "util" {
|
|
|
830
830
|
* Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
|
|
831
831
|
*
|
|
832
832
|
* ```js
|
|
833
|
-
*
|
|
833
|
+
* import util from 'node:util';
|
|
834
834
|
*
|
|
835
835
|
* const foo = undefined;
|
|
836
836
|
* util.isUndefined(5);
|
|
@@ -849,7 +849,7 @@ declare module "util" {
|
|
|
849
849
|
* such a way that it is marked as deprecated.
|
|
850
850
|
*
|
|
851
851
|
* ```js
|
|
852
|
-
*
|
|
852
|
+
* import util from 'node:util';
|
|
853
853
|
*
|
|
854
854
|
* exports.obsoleteFunction = util.deprecate(() => {
|
|
855
855
|
* // Do something here.
|
|
@@ -865,7 +865,7 @@ declare module "util" {
|
|
|
865
865
|
* the warning will be emitted only once for that `code`.
|
|
866
866
|
*
|
|
867
867
|
* ```js
|
|
868
|
-
*
|
|
868
|
+
* import util from 'node:util';
|
|
869
869
|
*
|
|
870
870
|
* const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
|
|
871
871
|
* const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
|
|
@@ -919,7 +919,7 @@ declare module "util" {
|
|
|
919
919
|
* first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value.
|
|
920
920
|
*
|
|
921
921
|
* ```js
|
|
922
|
-
*
|
|
922
|
+
* import util from 'node:util';
|
|
923
923
|
*
|
|
924
924
|
* async function fn() {
|
|
925
925
|
* return 'hello world';
|
|
@@ -1045,8 +1045,8 @@ declare module "util" {
|
|
|
1045
1045
|
* that returns promises.
|
|
1046
1046
|
*
|
|
1047
1047
|
* ```js
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1048
|
+
* import util from 'node:util';
|
|
1049
|
+
* import fs from 'node:fs';
|
|
1050
1050
|
*
|
|
1051
1051
|
* const stat = util.promisify(fs.stat);
|
|
1052
1052
|
* stat('.').then((stats) => {
|
|
@@ -1059,8 +1059,8 @@ declare module "util" {
|
|
|
1059
1059
|
* Or, equivalently using `async function`s:
|
|
1060
1060
|
*
|
|
1061
1061
|
* ```js
|
|
1062
|
-
*
|
|
1063
|
-
*
|
|
1062
|
+
* import util from 'node:util';
|
|
1063
|
+
* import fs from 'node:fs';
|
|
1064
1064
|
*
|
|
1065
1065
|
* const stat = util.promisify(fs.stat);
|
|
1066
1066
|
*
|
|
@@ -1081,7 +1081,7 @@ declare module "util" {
|
|
|
1081
1081
|
* work as expected unless handled specially:
|
|
1082
1082
|
*
|
|
1083
1083
|
* ```js
|
|
1084
|
-
*
|
|
1084
|
+
* import util from 'node:util';
|
|
1085
1085
|
*
|
|
1086
1086
|
* class Foo {
|
|
1087
1087
|
* constructor() {
|
|
@@ -1248,7 +1248,7 @@ declare module "util" {
|
|
|
1248
1248
|
import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
|
|
1249
1249
|
global {
|
|
1250
1250
|
/**
|
|
1251
|
-
* `TextDecoder` class is a global reference for `
|
|
1251
|
+
* `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
|
|
1252
1252
|
* https://nodejs.org/api/globals.html#textdecoder
|
|
1253
1253
|
* @since v11.0.0
|
|
1254
1254
|
*/
|
|
@@ -1259,7 +1259,7 @@ declare module "util" {
|
|
|
1259
1259
|
: typeof _TextDecoder;
|
|
1260
1260
|
|
|
1261
1261
|
/**
|
|
1262
|
-
* `TextEncoder` class is a global reference for `
|
|
1262
|
+
* `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
|
|
1263
1263
|
* https://nodejs.org/api/globals.html#textencoder
|
|
1264
1264
|
* @since v11.0.0
|
|
1265
1265
|
*/
|