@types/node 18.16.3 → 20.0.0
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/README.md +1 -1
- node/assert.d.ts +68 -73
- node/async_hooks.d.ts +62 -42
- node/buffer.d.ts +123 -95
- node/child_process.d.ts +50 -54
- node/cluster.d.ts +12 -12
- node/console.d.ts +5 -5
- node/crypto.d.ts +209 -220
- node/dgram.d.ts +15 -15
- node/diagnostics_channel.d.ts +25 -26
- node/dns/promises.d.ts +6 -6
- node/dns.d.ts +16 -16
- node/domain.d.ts +3 -3
- node/events.d.ts +60 -60
- node/fs/promises.d.ts +74 -48
- node/fs.d.ts +91 -81
- node/http.d.ts +147 -144
- node/http2.d.ts +42 -46
- node/https.d.ts +52 -153
- node/index.d.ts +1 -1
- node/inspector.d.ts +10 -3
- node/module.d.ts +5 -4
- node/net.d.ts +21 -18
- node/os.d.ts +22 -18
- node/package.json +2 -2
- node/path.d.ts +4 -4
- node/perf_hooks.d.ts +28 -15
- node/process.d.ts +43 -46
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +5 -5
- node/readline/promises.d.ts +6 -4
- node/readline.d.ts +15 -15
- node/repl.d.ts +9 -9
- node/stream/consumers.d.ts +1 -1
- node/stream.d.ts +74 -136
- node/string_decoder.d.ts +6 -6
- node/test.d.ts +0 -76
- node/timers/promises.d.ts +3 -3
- node/timers.d.ts +2 -2
- node/tls.d.ts +22 -15
- node/trace_events.d.ts +20 -9
- node/ts4.8/assert.d.ts +68 -73
- node/ts4.8/async_hooks.d.ts +59 -31
- node/ts4.8/buffer.d.ts +123 -95
- node/ts4.8/child_process.d.ts +50 -54
- node/ts4.8/cluster.d.ts +12 -12
- node/ts4.8/console.d.ts +5 -5
- node/ts4.8/crypto.d.ts +209 -220
- node/ts4.8/dgram.d.ts +15 -15
- node/ts4.8/diagnostics_channel.d.ts +25 -26
- node/ts4.8/dns/promises.d.ts +6 -6
- node/ts4.8/dns.d.ts +16 -16
- node/ts4.8/domain.d.ts +3 -3
- node/ts4.8/events.d.ts +60 -60
- node/ts4.8/fs/promises.d.ts +72 -45
- node/ts4.8/fs.d.ts +81 -67
- node/ts4.8/http.d.ts +133 -126
- node/ts4.8/http2.d.ts +42 -46
- node/ts4.8/https.d.ts +52 -153
- node/ts4.8/inspector.d.ts +10 -3
- node/ts4.8/module.d.ts +5 -4
- node/ts4.8/net.d.ts +21 -18
- node/ts4.8/os.d.ts +22 -18
- node/ts4.8/path.d.ts +4 -4
- node/ts4.8/perf_hooks.d.ts +28 -15
- node/ts4.8/process.d.ts +43 -46
- node/ts4.8/punycode.d.ts +1 -1
- node/ts4.8/querystring.d.ts +5 -5
- node/ts4.8/readline/promises.d.ts +6 -4
- node/ts4.8/readline.d.ts +15 -15
- node/ts4.8/repl.d.ts +9 -9
- node/ts4.8/stream/consumers.d.ts +1 -1
- node/ts4.8/stream.d.ts +77 -139
- node/ts4.8/string_decoder.d.ts +6 -6
- node/ts4.8/test.d.ts +0 -75
- node/ts4.8/timers/promises.d.ts +3 -3
- node/ts4.8/timers.d.ts +2 -2
- node/ts4.8/tls.d.ts +22 -15
- node/ts4.8/trace_events.d.ts +20 -9
- node/ts4.8/tty.d.ts +4 -5
- node/ts4.8/url.d.ts +26 -36
- node/ts4.8/util.d.ts +143 -116
- node/ts4.8/v8.d.ts +107 -16
- node/ts4.8/vm.d.ts +292 -42
- node/ts4.8/wasi.d.ts +8 -14
- node/ts4.8/worker_threads.d.ts +32 -34
- node/ts4.8/zlib.d.ts +11 -11
- node/tty.d.ts +4 -5
- node/url.d.ts +26 -36
- node/util.d.ts +146 -111
- node/v8.d.ts +110 -16
- node/vm.d.ts +292 -42
- node/wasi.d.ts +8 -14
- node/worker_threads.d.ts +32 -34
- node/zlib.d.ts +11 -11
node/trace_events.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `trace_events` module provides a mechanism to centralize tracing
|
|
3
|
-
* generated by V8, Node.js core, and userspace code.
|
|
2
|
+
* The `node:trace_events` module provides a mechanism to centralize tracing
|
|
3
|
+
* information generated by V8, Node.js core, and userspace code.
|
|
4
4
|
*
|
|
5
5
|
* Tracing can be enabled with the `--trace-event-categories` command-line flag
|
|
6
|
-
* or by using the `trace_events` module. The `--trace-event-categories` flag
|
|
6
|
+
* or by using the `node:trace_events` module. The `--trace-event-categories` flag
|
|
7
7
|
* accepts a list of comma-separated category names.
|
|
8
8
|
*
|
|
9
9
|
* The available categories are:
|
|
@@ -13,9 +13,19 @@
|
|
|
13
13
|
* The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
|
|
14
14
|
* * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
|
|
15
15
|
* * `node.console`: Enables capture of `console.time()` and `console.count()`output.
|
|
16
|
+
* * `node.threadpoolwork.sync`: Enables capture of trace data for threadpool
|
|
17
|
+
* synchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
|
18
|
+
* * `node.threadpoolwork.async`: Enables capture of trace data for threadpool
|
|
19
|
+
* asynchronous operations, such as `blob`, `zlib`, `crypto` and `node_api`.
|
|
16
20
|
* * `node.dns.native`: Enables capture of trace data for DNS queries.
|
|
21
|
+
* * `node.net.native`: Enables capture of trace data for network.
|
|
17
22
|
* * `node.environment`: Enables capture of Node.js Environment milestones.
|
|
18
23
|
* * `node.fs.sync`: Enables capture of trace data for file system sync methods.
|
|
24
|
+
* * `node.fs_dir.sync`: Enables capture of trace data for file system sync
|
|
25
|
+
* directory methods.
|
|
26
|
+
* * `node.fs.async`: Enables capture of trace data for file system async methods.
|
|
27
|
+
* * `node.fs_dir.async`: Enables capture of trace data for file system async
|
|
28
|
+
* directory methods.
|
|
19
29
|
* * `node.perf`: Enables capture of `Performance API` measurements.
|
|
20
30
|
* * `node.perf.usertiming`: Enables capture of only Performance API User Timing
|
|
21
31
|
* measures and marks.
|
|
@@ -23,8 +33,9 @@
|
|
|
23
33
|
* measurements.
|
|
24
34
|
* * `node.promises.rejections`: Enables capture of trace data tracking the number
|
|
25
35
|
* of unhandled Promise rejections and handled-after-rejections.
|
|
26
|
-
* * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
|
36
|
+
* * `node.vm.script`: Enables capture of trace data for the `node:vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
|
|
27
37
|
* * `v8`: The `V8` events are GC, compiling, and execution related.
|
|
38
|
+
* * `node.http`: Enables capture of trace data for http request / response.
|
|
28
39
|
*
|
|
29
40
|
* By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
|
|
30
41
|
*
|
|
@@ -43,10 +54,10 @@
|
|
|
43
54
|
* node --trace-event-categories v8,node,node.async_hooks
|
|
44
55
|
* ```
|
|
45
56
|
*
|
|
46
|
-
* Alternatively, trace events may be enabled using the `trace_events` module:
|
|
57
|
+
* Alternatively, trace events may be enabled using the `node:trace_events` module:
|
|
47
58
|
*
|
|
48
59
|
* ```js
|
|
49
|
-
* const trace_events = require('trace_events');
|
|
60
|
+
* const trace_events = require('node:trace_events');
|
|
50
61
|
* const tracing = trace_events.createTracing({ categories: ['node.perf'] });
|
|
51
62
|
* tracing.enable(); // Enable trace event capture for the 'node.perf' category
|
|
52
63
|
*
|
|
@@ -83,7 +94,7 @@
|
|
|
83
94
|
*
|
|
84
95
|
* The features from this module are not available in `Worker` threads.
|
|
85
96
|
* @experimental
|
|
86
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
97
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.0.0/lib/trace_events.js)
|
|
87
98
|
*/
|
|
88
99
|
declare module 'trace_events' {
|
|
89
100
|
/**
|
|
@@ -132,7 +143,7 @@ declare module 'trace_events' {
|
|
|
132
143
|
* Creates and returns a `Tracing` object for the given set of `categories`.
|
|
133
144
|
*
|
|
134
145
|
* ```js
|
|
135
|
-
* const trace_events = require('trace_events');
|
|
146
|
+
* const trace_events = require('node:trace_events');
|
|
136
147
|
* const categories = ['node.perf', 'node.async_hooks'];
|
|
137
148
|
* const tracing = trace_events.createTracing({ categories });
|
|
138
149
|
* tracing.enable();
|
|
@@ -152,7 +163,7 @@ declare module 'trace_events' {
|
|
|
152
163
|
* 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
164
|
*
|
|
154
165
|
* ```js
|
|
155
|
-
* const trace_events = require('trace_events');
|
|
166
|
+
* const trace_events = require('node:trace_events');
|
|
156
167
|
* const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
|
|
157
168
|
* const t2 = trace_events.createTracing({ categories: ['node.perf'] });
|
|
158
169
|
* const t3 = trace_events.createTracing({ categories: ['v8'] });
|
node/ts4.8/assert.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `assert` module provides a set of assertion functions for verifying
|
|
2
|
+
* The `node:assert` module provides a set of assertion functions for verifying
|
|
3
3
|
* invariants.
|
|
4
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
4
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.0.0/lib/assert.js)
|
|
5
5
|
*/
|
|
6
6
|
declare module 'assert' {
|
|
7
7
|
/**
|
|
@@ -12,8 +12,7 @@ declare module 'assert' {
|
|
|
12
12
|
function assert(value: unknown, message?: string | Error): asserts value;
|
|
13
13
|
namespace assert {
|
|
14
14
|
/**
|
|
15
|
-
* Indicates the failure of an assertion. All errors thrown by the `assert`
|
|
16
|
-
* will be instances of the `AssertionError` class.
|
|
15
|
+
* Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class.
|
|
17
16
|
*/
|
|
18
17
|
class AssertionError extends Error {
|
|
19
18
|
actual: unknown;
|
|
@@ -47,7 +46,7 @@ declare module 'assert' {
|
|
|
47
46
|
* error.
|
|
48
47
|
*
|
|
49
48
|
* ```js
|
|
50
|
-
* import assert from 'assert';
|
|
49
|
+
* import assert from 'node:assert';
|
|
51
50
|
*
|
|
52
51
|
* // Creates call tracker.
|
|
53
52
|
* const tracker = new assert.CallTracker();
|
|
@@ -78,12 +77,11 @@ declare module 'assert' {
|
|
|
78
77
|
* callsfunc(1, 2, 3);
|
|
79
78
|
*
|
|
80
79
|
* assert.deepStrictEqual(tracker.getCalls(callsfunc),
|
|
81
|
-
* [{ thisArg:
|
|
80
|
+
* [{ thisArg: undefined, arguments: [1, 2, 3] }]);
|
|
82
81
|
* ```
|
|
83
|
-
*
|
|
84
82
|
* @since v18.8.0, v16.18.0
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
83
|
+
* @param fn
|
|
84
|
+
* @return An Array with the calls to a tracked function.
|
|
87
85
|
*/
|
|
88
86
|
getCalls(fn: Function): CallTrackerCall[];
|
|
89
87
|
/**
|
|
@@ -91,21 +89,19 @@ declare module 'assert' {
|
|
|
91
89
|
* the functions that have not been called the expected number of times.
|
|
92
90
|
*
|
|
93
91
|
* ```js
|
|
94
|
-
* import assert from 'assert';
|
|
92
|
+
* import assert from 'node:assert';
|
|
95
93
|
*
|
|
96
94
|
* // Creates call tracker.
|
|
97
95
|
* const tracker = new assert.CallTracker();
|
|
98
96
|
*
|
|
99
97
|
* function func() {}
|
|
100
98
|
*
|
|
101
|
-
* function foo() {}
|
|
102
|
-
*
|
|
103
99
|
* // Returns a function that wraps func() that must be called exact times
|
|
104
100
|
* // before tracker.verify().
|
|
105
101
|
* const callsfunc = tracker.calls(func, 2);
|
|
106
102
|
*
|
|
107
103
|
* // Returns an array containing information on callsfunc()
|
|
108
|
-
* tracker.report();
|
|
104
|
+
* console.log(tracker.report());
|
|
109
105
|
* // [
|
|
110
106
|
* // {
|
|
111
107
|
* // message: 'Expected the func function to be executed 2 time(s) but was
|
|
@@ -118,7 +114,7 @@ declare module 'assert' {
|
|
|
118
114
|
* // ]
|
|
119
115
|
* ```
|
|
120
116
|
* @since v14.2.0, v12.19.0
|
|
121
|
-
* @return of objects containing information about the wrapper functions returned by `calls`.
|
|
117
|
+
* @return An Array of objects containing information about the wrapper functions returned by `calls`.
|
|
122
118
|
*/
|
|
123
119
|
report(): CallTrackerReportInformation[];
|
|
124
120
|
/**
|
|
@@ -136,12 +132,11 @@ declare module 'assert' {
|
|
|
136
132
|
*
|
|
137
133
|
* callsfunc();
|
|
138
134
|
* // Tracker was called once
|
|
139
|
-
* tracker.getCalls(callsfunc).length
|
|
135
|
+
* assert.strictEqual(tracker.getCalls(callsfunc).length, 1);
|
|
140
136
|
*
|
|
141
137
|
* tracker.reset(callsfunc);
|
|
142
|
-
* tracker.getCalls(callsfunc).length
|
|
138
|
+
* assert.strictEqual(tracker.getCalls(callsfunc).length, 0);
|
|
143
139
|
* ```
|
|
144
|
-
*
|
|
145
140
|
* @since v18.8.0, v16.18.0
|
|
146
141
|
* @param fn a tracked function to reset.
|
|
147
142
|
*/
|
|
@@ -151,7 +146,7 @@ declare module 'assert' {
|
|
|
151
146
|
* have not been called the expected number of times.
|
|
152
147
|
*
|
|
153
148
|
* ```js
|
|
154
|
-
* import assert from 'assert';
|
|
149
|
+
* import assert from 'node:assert';
|
|
155
150
|
*
|
|
156
151
|
* // Creates call tracker.
|
|
157
152
|
* const tracker = new assert.CallTracker();
|
|
@@ -193,7 +188,7 @@ declare module 'assert' {
|
|
|
193
188
|
* it will be thrown instead of the `AssertionError`.
|
|
194
189
|
*
|
|
195
190
|
* ```js
|
|
196
|
-
* import assert from 'assert/strict';
|
|
191
|
+
* import assert from 'node:assert/strict';
|
|
197
192
|
*
|
|
198
193
|
* assert.fail();
|
|
199
194
|
* // AssertionError [ERR_ASSERTION]: Failed
|
|
@@ -231,7 +226,7 @@ declare module 'assert' {
|
|
|
231
226
|
* thrown in a file! See below for further details.
|
|
232
227
|
*
|
|
233
228
|
* ```js
|
|
234
|
-
* import assert from 'assert/strict';
|
|
229
|
+
* import assert from 'node:assert/strict';
|
|
235
230
|
*
|
|
236
231
|
* assert.ok(true);
|
|
237
232
|
* // OK
|
|
@@ -266,7 +261,7 @@ declare module 'assert' {
|
|
|
266
261
|
* ```
|
|
267
262
|
*
|
|
268
263
|
* ```js
|
|
269
|
-
* import assert from 'assert/strict';
|
|
264
|
+
* import assert from 'node:assert/strict';
|
|
270
265
|
*
|
|
271
266
|
* // Using `assert()` works the same:
|
|
272
267
|
* assert(0);
|
|
@@ -291,7 +286,7 @@ declare module 'assert' {
|
|
|
291
286
|
* and treated as being identical if both sides are `NaN`.
|
|
292
287
|
*
|
|
293
288
|
* ```js
|
|
294
|
-
* import assert from 'assert';
|
|
289
|
+
* import assert from 'node:assert';
|
|
295
290
|
*
|
|
296
291
|
* assert.equal(1, 1);
|
|
297
292
|
* // OK, 1 == 1
|
|
@@ -324,7 +319,7 @@ declare module 'assert' {
|
|
|
324
319
|
* specially handled and treated as being identical if both sides are `NaN`.
|
|
325
320
|
*
|
|
326
321
|
* ```js
|
|
327
|
-
* import assert from 'assert';
|
|
322
|
+
* import assert from 'node:assert';
|
|
328
323
|
*
|
|
329
324
|
* assert.notEqual(1, 2);
|
|
330
325
|
* // OK
|
|
@@ -371,24 +366,24 @@ declare module 'assert' {
|
|
|
371
366
|
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
|
372
367
|
*
|
|
373
368
|
* ```js
|
|
374
|
-
* import assert from 'assert';
|
|
369
|
+
* import assert from 'node:assert';
|
|
375
370
|
*
|
|
376
371
|
* const obj1 = {
|
|
377
372
|
* a: {
|
|
378
|
-
* b: 1
|
|
379
|
-
* }
|
|
373
|
+
* b: 1,
|
|
374
|
+
* },
|
|
380
375
|
* };
|
|
381
376
|
* const obj2 = {
|
|
382
377
|
* a: {
|
|
383
|
-
* b: 2
|
|
384
|
-
* }
|
|
378
|
+
* b: 2,
|
|
379
|
+
* },
|
|
385
380
|
* };
|
|
386
381
|
* const obj3 = {
|
|
387
382
|
* a: {
|
|
388
|
-
* b: 1
|
|
389
|
-
* }
|
|
383
|
+
* b: 1,
|
|
384
|
+
* },
|
|
390
385
|
* };
|
|
391
|
-
* const obj4 =
|
|
386
|
+
* const obj4 = { __proto__: obj1 };
|
|
392
387
|
*
|
|
393
388
|
* assert.notDeepEqual(obj1, obj1);
|
|
394
389
|
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
|
@@ -414,7 +409,7 @@ declare module 'assert' {
|
|
|
414
409
|
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
|
415
410
|
*
|
|
416
411
|
* ```js
|
|
417
|
-
* import assert from 'assert/strict';
|
|
412
|
+
* import assert from 'node:assert/strict';
|
|
418
413
|
*
|
|
419
414
|
* assert.strictEqual(1, 2);
|
|
420
415
|
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
|
@@ -452,7 +447,7 @@ declare module 'assert' {
|
|
|
452
447
|
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
|
453
448
|
*
|
|
454
449
|
* ```js
|
|
455
|
-
* import assert from 'assert/strict';
|
|
450
|
+
* import assert from 'node:assert/strict';
|
|
456
451
|
*
|
|
457
452
|
* assert.notStrictEqual(1, 2);
|
|
458
453
|
* // OK
|
|
@@ -483,7 +478,7 @@ declare module 'assert' {
|
|
|
483
478
|
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
|
484
479
|
*
|
|
485
480
|
* ```js
|
|
486
|
-
* import assert from 'assert/strict';
|
|
481
|
+
* import assert from 'node:assert/strict';
|
|
487
482
|
*
|
|
488
483
|
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
|
489
484
|
* // OK
|
|
@@ -514,14 +509,14 @@ declare module 'assert' {
|
|
|
514
509
|
* Custom validation object/error instance:
|
|
515
510
|
*
|
|
516
511
|
* ```js
|
|
517
|
-
* import assert from 'assert/strict';
|
|
512
|
+
* import assert from 'node:assert/strict';
|
|
518
513
|
*
|
|
519
514
|
* const err = new TypeError('Wrong value');
|
|
520
515
|
* err.code = 404;
|
|
521
516
|
* err.foo = 'bar';
|
|
522
517
|
* err.info = {
|
|
523
518
|
* nested: true,
|
|
524
|
-
* baz: 'text'
|
|
519
|
+
* baz: 'text',
|
|
525
520
|
* };
|
|
526
521
|
* err.reg = /abc/i;
|
|
527
522
|
*
|
|
@@ -534,16 +529,16 @@ declare module 'assert' {
|
|
|
534
529
|
* message: 'Wrong value',
|
|
535
530
|
* info: {
|
|
536
531
|
* nested: true,
|
|
537
|
-
* baz: 'text'
|
|
538
|
-
* }
|
|
532
|
+
* baz: 'text',
|
|
533
|
+
* },
|
|
539
534
|
* // Only properties on the validation object will be tested for.
|
|
540
535
|
* // Using nested objects requires all properties to be present. Otherwise
|
|
541
536
|
* // the validation is going to fail.
|
|
542
|
-
* }
|
|
537
|
+
* },
|
|
543
538
|
* );
|
|
544
539
|
*
|
|
545
540
|
* // Using regular expressions to validate error properties:
|
|
546
|
-
* throws(
|
|
541
|
+
* assert.throws(
|
|
547
542
|
* () => {
|
|
548
543
|
* throw err;
|
|
549
544
|
* },
|
|
@@ -557,17 +552,17 @@ declare module 'assert' {
|
|
|
557
552
|
* info: {
|
|
558
553
|
* nested: true,
|
|
559
554
|
* // It is not possible to use regular expressions for nested properties!
|
|
560
|
-
* baz: 'text'
|
|
555
|
+
* baz: 'text',
|
|
561
556
|
* },
|
|
562
557
|
* // The `reg` property contains a regular expression and only if the
|
|
563
558
|
* // validation object contains an identical regular expression, it is going
|
|
564
559
|
* // to pass.
|
|
565
|
-
* reg: /abc/i
|
|
566
|
-
* }
|
|
560
|
+
* reg: /abc/i,
|
|
561
|
+
* },
|
|
567
562
|
* );
|
|
568
563
|
*
|
|
569
564
|
* // Fails due to the different `message` and `name` properties:
|
|
570
|
-
* throws(
|
|
565
|
+
* assert.throws(
|
|
571
566
|
* () => {
|
|
572
567
|
* const otherErr = new Error('Not found');
|
|
573
568
|
* // Copy all enumerable properties from `err` to `otherErr`.
|
|
@@ -578,20 +573,20 @@ declare module 'assert' {
|
|
|
578
573
|
* },
|
|
579
574
|
* // The error's `message` and `name` properties will also be checked when using
|
|
580
575
|
* // an error as validation object.
|
|
581
|
-
* err
|
|
576
|
+
* err,
|
|
582
577
|
* );
|
|
583
578
|
* ```
|
|
584
579
|
*
|
|
585
580
|
* Validate instanceof using constructor:
|
|
586
581
|
*
|
|
587
582
|
* ```js
|
|
588
|
-
* import assert from 'assert/strict';
|
|
583
|
+
* import assert from 'node:assert/strict';
|
|
589
584
|
*
|
|
590
585
|
* assert.throws(
|
|
591
586
|
* () => {
|
|
592
587
|
* throw new Error('Wrong value');
|
|
593
588
|
* },
|
|
594
|
-
* Error
|
|
589
|
+
* Error,
|
|
595
590
|
* );
|
|
596
591
|
* ```
|
|
597
592
|
*
|
|
@@ -601,13 +596,13 @@ declare module 'assert' {
|
|
|
601
596
|
* therefore also include the error name.
|
|
602
597
|
*
|
|
603
598
|
* ```js
|
|
604
|
-
* import assert from 'assert/strict';
|
|
599
|
+
* import assert from 'node:assert/strict';
|
|
605
600
|
*
|
|
606
601
|
* assert.throws(
|
|
607
602
|
* () => {
|
|
608
603
|
* throw new Error('Wrong value');
|
|
609
604
|
* },
|
|
610
|
-
* /^Error: Wrong value
|
|
605
|
+
* /^Error: Wrong value$/,
|
|
611
606
|
* );
|
|
612
607
|
* ```
|
|
613
608
|
*
|
|
@@ -617,7 +612,7 @@ declare module 'assert' {
|
|
|
617
612
|
* It will otherwise fail with an `AssertionError`.
|
|
618
613
|
*
|
|
619
614
|
* ```js
|
|
620
|
-
* import assert from 'assert/strict';
|
|
615
|
+
* import assert from 'node:assert/strict';
|
|
621
616
|
*
|
|
622
617
|
* assert.throws(
|
|
623
618
|
* () => {
|
|
@@ -633,7 +628,7 @@ declare module 'assert' {
|
|
|
633
628
|
* // possible.
|
|
634
629
|
* return true;
|
|
635
630
|
* },
|
|
636
|
-
* 'unexpected error'
|
|
631
|
+
* 'unexpected error',
|
|
637
632
|
* );
|
|
638
633
|
* ```
|
|
639
634
|
*
|
|
@@ -643,7 +638,7 @@ declare module 'assert' {
|
|
|
643
638
|
* a string as the second argument gets considered:
|
|
644
639
|
*
|
|
645
640
|
* ```js
|
|
646
|
-
* import assert from 'assert/strict';
|
|
641
|
+
* import assert from 'node:assert/strict';
|
|
647
642
|
*
|
|
648
643
|
* function throwingFirst() {
|
|
649
644
|
* throw new Error('First');
|
|
@@ -699,20 +694,20 @@ declare module 'assert' {
|
|
|
699
694
|
* propagated back to the caller.
|
|
700
695
|
*
|
|
701
696
|
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
702
|
-
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
|
697
|
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
|
703
698
|
* function. See {@link throws} for more details.
|
|
704
699
|
*
|
|
705
700
|
* The following, for instance, will throw the `TypeError` because there is no
|
|
706
701
|
* matching error type in the assertion:
|
|
707
702
|
*
|
|
708
703
|
* ```js
|
|
709
|
-
* import assert from 'assert/strict';
|
|
704
|
+
* import assert from 'node:assert/strict';
|
|
710
705
|
*
|
|
711
706
|
* assert.doesNotThrow(
|
|
712
707
|
* () => {
|
|
713
708
|
* throw new TypeError('Wrong value');
|
|
714
709
|
* },
|
|
715
|
-
* SyntaxError
|
|
710
|
+
* SyntaxError,
|
|
716
711
|
* );
|
|
717
712
|
* ```
|
|
718
713
|
*
|
|
@@ -720,27 +715,27 @@ declare module 'assert' {
|
|
|
720
715
|
* 'Got unwanted exception...':
|
|
721
716
|
*
|
|
722
717
|
* ```js
|
|
723
|
-
* import assert from 'assert/strict';
|
|
718
|
+
* import assert from 'node:assert/strict';
|
|
724
719
|
*
|
|
725
720
|
* assert.doesNotThrow(
|
|
726
721
|
* () => {
|
|
727
722
|
* throw new TypeError('Wrong value');
|
|
728
723
|
* },
|
|
729
|
-
* TypeError
|
|
724
|
+
* TypeError,
|
|
730
725
|
* );
|
|
731
726
|
* ```
|
|
732
727
|
*
|
|
733
728
|
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
|
734
729
|
*
|
|
735
730
|
* ```js
|
|
736
|
-
* import assert from 'assert/strict';
|
|
731
|
+
* import assert from 'node:assert/strict';
|
|
737
732
|
*
|
|
738
733
|
* assert.doesNotThrow(
|
|
739
734
|
* () => {
|
|
740
735
|
* throw new TypeError('Wrong value');
|
|
741
736
|
* },
|
|
742
737
|
* /Wrong value/,
|
|
743
|
-
* 'Whoops'
|
|
738
|
+
* 'Whoops',
|
|
744
739
|
* );
|
|
745
740
|
* // Throws: AssertionError: Got unwanted exception: Whoops
|
|
746
741
|
* ```
|
|
@@ -754,7 +749,7 @@ declare module 'assert' {
|
|
|
754
749
|
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
|
755
750
|
*
|
|
756
751
|
* ```js
|
|
757
|
-
* import assert from 'assert/strict';
|
|
752
|
+
* import assert from 'node:assert/strict';
|
|
758
753
|
*
|
|
759
754
|
* assert.ifError(null);
|
|
760
755
|
* // OK
|
|
@@ -800,7 +795,7 @@ declare module 'assert' {
|
|
|
800
795
|
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
|
801
796
|
*
|
|
802
797
|
* ```js
|
|
803
|
-
* import assert from 'assert/strict';
|
|
798
|
+
* import assert from 'node:assert/strict';
|
|
804
799
|
*
|
|
805
800
|
* await assert.rejects(
|
|
806
801
|
* async () => {
|
|
@@ -808,13 +803,13 @@ declare module 'assert' {
|
|
|
808
803
|
* },
|
|
809
804
|
* {
|
|
810
805
|
* name: 'TypeError',
|
|
811
|
-
* message: 'Wrong value'
|
|
812
|
-
* }
|
|
806
|
+
* message: 'Wrong value',
|
|
807
|
+
* },
|
|
813
808
|
* );
|
|
814
809
|
* ```
|
|
815
810
|
*
|
|
816
811
|
* ```js
|
|
817
|
-
* import assert from 'assert/strict';
|
|
812
|
+
* import assert from 'node:assert/strict';
|
|
818
813
|
*
|
|
819
814
|
* await assert.rejects(
|
|
820
815
|
* async () => {
|
|
@@ -824,16 +819,16 @@ declare module 'assert' {
|
|
|
824
819
|
* assert.strictEqual(err.name, 'TypeError');
|
|
825
820
|
* assert.strictEqual(err.message, 'Wrong value');
|
|
826
821
|
* return true;
|
|
827
|
-
* }
|
|
822
|
+
* },
|
|
828
823
|
* );
|
|
829
824
|
* ```
|
|
830
825
|
*
|
|
831
826
|
* ```js
|
|
832
|
-
* import assert from 'assert/strict';
|
|
827
|
+
* import assert from 'node:assert/strict';
|
|
833
828
|
*
|
|
834
829
|
* assert.rejects(
|
|
835
830
|
* Promise.reject(new Error('Wrong value')),
|
|
836
|
-
* Error
|
|
831
|
+
* Error,
|
|
837
832
|
* ).then(() => {
|
|
838
833
|
* // ...
|
|
839
834
|
* });
|
|
@@ -863,24 +858,24 @@ declare module 'assert' {
|
|
|
863
858
|
* error messages as expressive as possible.
|
|
864
859
|
*
|
|
865
860
|
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
|
866
|
-
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
|
861
|
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
|
867
862
|
* function. See {@link throws} for more details.
|
|
868
863
|
*
|
|
869
864
|
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
|
870
865
|
*
|
|
871
866
|
* ```js
|
|
872
|
-
* import assert from 'assert/strict';
|
|
867
|
+
* import assert from 'node:assert/strict';
|
|
873
868
|
*
|
|
874
869
|
* await assert.doesNotReject(
|
|
875
870
|
* async () => {
|
|
876
871
|
* throw new TypeError('Wrong value');
|
|
877
872
|
* },
|
|
878
|
-
* SyntaxError
|
|
873
|
+
* SyntaxError,
|
|
879
874
|
* );
|
|
880
875
|
* ```
|
|
881
876
|
*
|
|
882
877
|
* ```js
|
|
883
|
-
* import assert from 'assert/strict';
|
|
878
|
+
* import assert from 'node:assert/strict';
|
|
884
879
|
*
|
|
885
880
|
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
|
886
881
|
* .then(() => {
|
|
@@ -895,7 +890,7 @@ declare module 'assert' {
|
|
|
895
890
|
* Expects the `string` input to match the regular expression.
|
|
896
891
|
*
|
|
897
892
|
* ```js
|
|
898
|
-
* import assert from 'assert/strict';
|
|
893
|
+
* import assert from 'node:assert/strict';
|
|
899
894
|
*
|
|
900
895
|
* assert.match('I will fail', /pass/);
|
|
901
896
|
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
|
@@ -918,7 +913,7 @@ declare module 'assert' {
|
|
|
918
913
|
* Expects the `string` input not to match the regular expression.
|
|
919
914
|
*
|
|
920
915
|
* ```js
|
|
921
|
-
* import assert from 'assert/strict';
|
|
916
|
+
* import assert from 'node:assert/strict';
|
|
922
917
|
*
|
|
923
918
|
* assert.doesNotMatch('I will fail', /fail/);
|
|
924
919
|
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|