@types/node 16.11.39 → 18.11.2

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 (111) hide show
  1. {node v16.11 → node}/LICENSE +0 -0
  2. node v16.11/README.md → node/README.md +4 -4
  3. {node v16.11 → node}/assert/strict.d.ts +0 -0
  4. node v16.11/assert.d.ts → node/assert.d.ts +7 -8
  5. node v16.11/async_hooks.d.ts → node/async_hooks.d.ts +8 -4
  6. node/buffer.d.ts +2258 -0
  7. node v16.11/child_process.d.ts → node/child_process.d.ts +6 -3
  8. node v16.11/cluster.d.ts → node/cluster.d.ts +14 -18
  9. node v16.11/console.d.ts → node/console.d.ts +1 -1
  10. {node v16.11 → node}/constants.d.ts +0 -0
  11. node v16.11/crypto.d.ts → node/crypto.d.ts +679 -53
  12. node v16.11/dgram.d.ts → node/dgram.d.ts +3 -3
  13. node v16.11/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
  14. node v16.11/dns/promises.d.ts → node/dns/promises.d.ts +10 -8
  15. node v16.11/dns.d.ts → node/dns.d.ts +16 -11
  16. node/dom-events.d.ts +126 -0
  17. node v16.11/domain.d.ts → node/domain.d.ts +3 -2
  18. node v16.11/events.d.ts → node/events.d.ts +65 -10
  19. node v16.11/fs/promises.d.ts → node/fs/promises.d.ts +86 -39
  20. node v16.11/fs.d.ts → node/fs.d.ts +149 -67
  21. node/globals.d.ts +300 -0
  22. {node v16.11 → node}/globals.global.d.ts +0 -0
  23. node v16.11/http.d.ts → node/http.d.ts +305 -77
  24. node v16.11/http2.d.ts → node/http2.d.ts +38 -5
  25. node v16.11/https.d.ts → node/https.d.ts +209 -59
  26. node v16.11/index.d.ts → node/index.d.ts +6 -3
  27. node v16.11/inspector.d.ts → node/inspector.d.ts +11 -15
  28. {node v16.11 → node}/module.d.ts +0 -0
  29. node v16.11/net.d.ts → node/net.d.ts +94 -21
  30. node v16.11/os.d.ts → node/os.d.ts +15 -4
  31. node v16.11/package.json → node/package.json +15 -8
  32. node v16.11/path.d.ts → node/path.d.ts +34 -23
  33. node v16.11/perf_hooks.d.ts → node/perf_hooks.d.ts +76 -8
  34. node v16.11/process.d.ts → node/process.d.ts +17 -16
  35. node v16.11/punycode.d.ts → node/punycode.d.ts +1 -1
  36. node v16.11/querystring.d.ts → node/querystring.d.ts +4 -4
  37. node/readline/promises.d.ts +143 -0
  38. node v16.11/readline.d.ts → node/readline.d.ts +140 -30
  39. node v16.11/repl.d.ts → node/repl.d.ts +2 -2
  40. node v16.11/stream/consumers.d.ts → node/stream/consumers.d.ts +2 -14
  41. {node v16.11 → node}/stream/promises.d.ts +0 -0
  42. node v16.11/stream/web.d.ts → node/stream/web.d.ts +3 -65
  43. node v16.11/stream.d.ts → node/stream.d.ts +97 -19
  44. node v16.11/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
  45. node/test.d.ts +314 -0
  46. {node v16.11 → node}/timers/promises.d.ts +0 -0
  47. node v16.11/timers.d.ts → node/timers.d.ts +1 -1
  48. node v16.11/tls.d.ts → node/tls.d.ts +32 -23
  49. node v16.11/trace_events.d.ts → node/trace_events.d.ts +11 -1
  50. node/ts4.8/assert/strict.d.ts +8 -0
  51. node/ts4.8/assert.d.ts +911 -0
  52. node/ts4.8/async_hooks.d.ts +501 -0
  53. node v16.11/buffer.d.ts → node/ts4.8/buffer.d.ts +46 -19
  54. node/ts4.8/child_process.d.ts +1369 -0
  55. node/ts4.8/cluster.d.ts +410 -0
  56. node/ts4.8/console.d.ts +412 -0
  57. node/ts4.8/constants.d.ts +18 -0
  58. node/ts4.8/crypto.d.ts +3964 -0
  59. node/ts4.8/dgram.d.ts +545 -0
  60. node/ts4.8/diagnostics_channel.d.ts +153 -0
  61. node/ts4.8/dns/promises.d.ts +370 -0
  62. node/ts4.8/dns.d.ts +659 -0
  63. node/ts4.8/dom-events.d.ts +126 -0
  64. node/ts4.8/domain.d.ts +170 -0
  65. node/ts4.8/events.d.ts +678 -0
  66. node/ts4.8/fs/promises.d.ts +1138 -0
  67. node/ts4.8/fs.d.ts +3872 -0
  68. node v16.11/globals.d.ts → node/ts4.8/globals.d.ts +14 -4
  69. node/ts4.8/globals.global.d.ts +1 -0
  70. node/ts4.8/http.d.ts +1607 -0
  71. node/ts4.8/http2.d.ts +2134 -0
  72. node/ts4.8/https.d.ts +541 -0
  73. node/ts4.8/index.d.ts +88 -0
  74. node/ts4.8/inspector.d.ts +2741 -0
  75. node/ts4.8/module.d.ts +114 -0
  76. node/ts4.8/net.d.ts +869 -0
  77. node/ts4.8/os.d.ts +466 -0
  78. node/ts4.8/path.d.ts +191 -0
  79. node/ts4.8/perf_hooks.d.ts +625 -0
  80. node/ts4.8/process.d.ts +1482 -0
  81. node/ts4.8/punycode.d.ts +117 -0
  82. node/ts4.8/querystring.d.ts +131 -0
  83. node/ts4.8/readline/promises.d.ts +143 -0
  84. node/ts4.8/readline.d.ts +653 -0
  85. node/ts4.8/repl.d.ts +424 -0
  86. node/ts4.8/stream/consumers.d.ts +12 -0
  87. node/ts4.8/stream/promises.d.ts +42 -0
  88. node/ts4.8/stream/web.d.ts +330 -0
  89. node/ts4.8/stream.d.ts +1340 -0
  90. node/ts4.8/string_decoder.d.ts +67 -0
  91. node/ts4.8/test.d.ts +314 -0
  92. node/ts4.8/timers/promises.d.ts +68 -0
  93. node/ts4.8/timers.d.ts +94 -0
  94. node/ts4.8/tls.d.ts +1028 -0
  95. node/ts4.8/trace_events.d.ts +171 -0
  96. node v16.11/tty.d.ts → node/ts4.8/tty.d.ts +4 -2
  97. node v16.11/url.d.ts → node/ts4.8/url.d.ts +85 -39
  98. node v16.11/util.d.ts → node/ts4.8/util.d.ts +268 -12
  99. node v16.11/v8.d.ts → node/ts4.8/v8.d.ts +21 -3
  100. node v16.11/vm.d.ts → node/ts4.8/vm.d.ts +6 -4
  101. node v16.11/wasi.d.ts → node/ts4.8/wasi.d.ts +1 -1
  102. node v16.11/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +50 -10
  103. node v16.11/zlib.d.ts → node/ts4.8/zlib.d.ts +1 -1
  104. node/tty.d.ts +206 -0
  105. node/url.d.ts +897 -0
  106. node/util.d.ts +1850 -0
  107. node/v8.d.ts +396 -0
  108. node/vm.d.ts +509 -0
  109. node/wasi.d.ts +158 -0
  110. node/worker_threads.d.ts +689 -0
  111. node/zlib.d.ts +517 -0
node/ts4.8/assert.d.ts ADDED
@@ -0,0 +1,911 @@
1
+ /**
2
+ * The `assert` module provides a set of assertion functions for verifying
3
+ * invariants.
4
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js)
5
+ */
6
+ declare module 'assert' {
7
+ /**
8
+ * An alias of {@link ok}.
9
+ * @since v0.5.9
10
+ * @param value The input that is checked for being truthy.
11
+ */
12
+ function assert(value: unknown, message?: string | Error): asserts value;
13
+ namespace assert {
14
+ /**
15
+ * Indicates the failure of an assertion. All errors thrown by the `assert` module
16
+ * will be instances of the `AssertionError` class.
17
+ */
18
+ class AssertionError extends Error {
19
+ actual: unknown;
20
+ expected: unknown;
21
+ operator: string;
22
+ generatedMessage: boolean;
23
+ code: 'ERR_ASSERTION';
24
+ constructor(options?: {
25
+ /** If provided, the error message is set to this value. */
26
+ message?: string | undefined;
27
+ /** The `actual` property on the error instance. */
28
+ actual?: unknown | undefined;
29
+ /** The `expected` property on the error instance. */
30
+ expected?: unknown | undefined;
31
+ /** The `operator` property on the error instance. */
32
+ operator?: string | undefined;
33
+ /** If provided, the generated stack trace omits frames before this function. */
34
+ // tslint:disable-next-line:ban-types
35
+ stackStartFn?: Function | undefined;
36
+ });
37
+ }
38
+ /**
39
+ * This feature is currently experimental and behavior might still change.
40
+ * @since v14.2.0, v12.19.0
41
+ * @experimental
42
+ */
43
+ class CallTracker {
44
+ /**
45
+ * The wrapper function is expected to be called exactly `exact` times. If the
46
+ * function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
47
+ * error.
48
+ *
49
+ * ```js
50
+ * import assert from 'assert';
51
+ *
52
+ * // Creates call tracker.
53
+ * const tracker = new assert.CallTracker();
54
+ *
55
+ * function func() {}
56
+ *
57
+ * // Returns a function that wraps func() that must be called exact times
58
+ * // before tracker.verify().
59
+ * const callsfunc = tracker.calls(func);
60
+ * ```
61
+ * @since v14.2.0, v12.19.0
62
+ * @param [fn='A no-op function']
63
+ * @param [exact=1]
64
+ * @return that wraps `fn`.
65
+ */
66
+ calls(exact?: number): () => void;
67
+ calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
68
+ /**
69
+ * The arrays contains information about the expected and actual number of calls of
70
+ * the functions that have not been called the expected number of times.
71
+ *
72
+ * ```js
73
+ * import assert from 'assert';
74
+ *
75
+ * // Creates call tracker.
76
+ * const tracker = new assert.CallTracker();
77
+ *
78
+ * function func() {}
79
+ *
80
+ * function foo() {}
81
+ *
82
+ * // Returns a function that wraps func() that must be called exact times
83
+ * // before tracker.verify().
84
+ * const callsfunc = tracker.calls(func, 2);
85
+ *
86
+ * // Returns an array containing information on callsfunc()
87
+ * tracker.report();
88
+ * // [
89
+ * // {
90
+ * // message: 'Expected the func function to be executed 2 time(s) but was
91
+ * // executed 0 time(s).',
92
+ * // actual: 0,
93
+ * // expected: 2,
94
+ * // operator: 'func',
95
+ * // stack: stack trace
96
+ * // }
97
+ * // ]
98
+ * ```
99
+ * @since v14.2.0, v12.19.0
100
+ * @return of objects containing information about the wrapper functions returned by `calls`.
101
+ */
102
+ report(): CallTrackerReportInformation[];
103
+ /**
104
+ * Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
105
+ * have not been called the expected number of times.
106
+ *
107
+ * ```js
108
+ * import assert from 'assert';
109
+ *
110
+ * // Creates call tracker.
111
+ * const tracker = new assert.CallTracker();
112
+ *
113
+ * function func() {}
114
+ *
115
+ * // Returns a function that wraps func() that must be called exact times
116
+ * // before tracker.verify().
117
+ * const callsfunc = tracker.calls(func, 2);
118
+ *
119
+ * callsfunc();
120
+ *
121
+ * // Will throw an error since callsfunc() was only called once.
122
+ * tracker.verify();
123
+ * ```
124
+ * @since v14.2.0, v12.19.0
125
+ */
126
+ verify(): void;
127
+ }
128
+ interface CallTrackerReportInformation {
129
+ message: string;
130
+ /** The actual number of times the function was called. */
131
+ actual: number;
132
+ /** The number of times the function was expected to be called. */
133
+ expected: number;
134
+ /** The name of the function that is wrapped. */
135
+ operator: string;
136
+ /** A stack trace of the function. */
137
+ stack: object;
138
+ }
139
+ type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
140
+ /**
141
+ * Throws an `AssertionError` with the provided error message or a default
142
+ * error message. If the `message` parameter is an instance of an `Error` then
143
+ * it will be thrown instead of the `AssertionError`.
144
+ *
145
+ * ```js
146
+ * import assert from 'assert/strict';
147
+ *
148
+ * assert.fail();
149
+ * // AssertionError [ERR_ASSERTION]: Failed
150
+ *
151
+ * assert.fail('boom');
152
+ * // AssertionError [ERR_ASSERTION]: boom
153
+ *
154
+ * assert.fail(new TypeError('need array'));
155
+ * // TypeError: need array
156
+ * ```
157
+ *
158
+ * Using `assert.fail()` with more than two arguments is possible but deprecated.
159
+ * See below for further details.
160
+ * @since v0.1.21
161
+ * @param [message='Failed']
162
+ */
163
+ function fail(message?: string | Error): never;
164
+ /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
165
+ function fail(
166
+ actual: unknown,
167
+ expected: unknown,
168
+ message?: string | Error,
169
+ operator?: string,
170
+ // tslint:disable-next-line:ban-types
171
+ stackStartFn?: Function
172
+ ): never;
173
+ /**
174
+ * Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
175
+ *
176
+ * If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
177
+ * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
178
+ * If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
179
+ *
180
+ * Be aware that in the `repl` the error message will be different to the one
181
+ * thrown in a file! See below for further details.
182
+ *
183
+ * ```js
184
+ * import assert from 'assert/strict';
185
+ *
186
+ * assert.ok(true);
187
+ * // OK
188
+ * assert.ok(1);
189
+ * // OK
190
+ *
191
+ * assert.ok();
192
+ * // AssertionError: No value argument passed to `assert.ok()`
193
+ *
194
+ * assert.ok(false, 'it\'s false');
195
+ * // AssertionError: it's false
196
+ *
197
+ * // In the repl:
198
+ * assert.ok(typeof 123 === 'string');
199
+ * // AssertionError: false == true
200
+ *
201
+ * // In a file (e.g. test.js):
202
+ * assert.ok(typeof 123 === 'string');
203
+ * // AssertionError: The expression evaluated to a falsy value:
204
+ * //
205
+ * // assert.ok(typeof 123 === 'string')
206
+ *
207
+ * assert.ok(false);
208
+ * // AssertionError: The expression evaluated to a falsy value:
209
+ * //
210
+ * // assert.ok(false)
211
+ *
212
+ * assert.ok(0);
213
+ * // AssertionError: The expression evaluated to a falsy value:
214
+ * //
215
+ * // assert.ok(0)
216
+ * ```
217
+ *
218
+ * ```js
219
+ * import assert from 'assert/strict';
220
+ *
221
+ * // Using `assert()` works the same:
222
+ * assert(0);
223
+ * // AssertionError: The expression evaluated to a falsy value:
224
+ * //
225
+ * // assert(0)
226
+ * ```
227
+ * @since v0.1.21
228
+ */
229
+ function ok(value: unknown, message?: string | Error): asserts value;
230
+ /**
231
+ * **Strict assertion mode**
232
+ *
233
+ * An alias of {@link strictEqual}.
234
+ *
235
+ * **Legacy assertion mode**
236
+ *
237
+ * > Stability: 3 - Legacy: Use {@link strictEqual} instead.
238
+ *
239
+ * Tests shallow, coercive equality between the `actual` and `expected` parameters
240
+ * using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
241
+ * and treated as being identical if both sides are `NaN`.
242
+ *
243
+ * ```js
244
+ * import assert from 'assert';
245
+ *
246
+ * assert.equal(1, 1);
247
+ * // OK, 1 == 1
248
+ * assert.equal(1, '1');
249
+ * // OK, 1 == '1'
250
+ * assert.equal(NaN, NaN);
251
+ * // OK
252
+ *
253
+ * assert.equal(1, 2);
254
+ * // AssertionError: 1 == 2
255
+ * assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
256
+ * // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
257
+ * ```
258
+ *
259
+ * If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
260
+ * error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
261
+ * @since v0.1.21
262
+ */
263
+ function equal(actual: unknown, expected: unknown, message?: string | Error): void;
264
+ /**
265
+ * **Strict assertion mode**
266
+ *
267
+ * An alias of {@link notStrictEqual}.
268
+ *
269
+ * **Legacy assertion mode**
270
+ *
271
+ * > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
272
+ *
273
+ * Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
274
+ * specially handled and treated as being identical if both sides are `NaN`.
275
+ *
276
+ * ```js
277
+ * import assert from 'assert';
278
+ *
279
+ * assert.notEqual(1, 2);
280
+ * // OK
281
+ *
282
+ * assert.notEqual(1, 1);
283
+ * // AssertionError: 1 != 1
284
+ *
285
+ * assert.notEqual(1, '1');
286
+ * // AssertionError: 1 != '1'
287
+ * ```
288
+ *
289
+ * If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
290
+ * message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
291
+ * @since v0.1.21
292
+ */
293
+ function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
294
+ /**
295
+ * **Strict assertion mode**
296
+ *
297
+ * An alias of {@link deepStrictEqual}.
298
+ *
299
+ * **Legacy assertion mode**
300
+ *
301
+ * > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
302
+ *
303
+ * Tests for deep equality between the `actual` and `expected` parameters. Consider
304
+ * using {@link deepStrictEqual} instead. {@link deepEqual} can have
305
+ * surprising results.
306
+ *
307
+ * _Deep equality_ means that the enumerable "own" properties of child objects
308
+ * are also recursively evaluated by the following rules.
309
+ * @since v0.1.21
310
+ */
311
+ function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
312
+ /**
313
+ * **Strict assertion mode**
314
+ *
315
+ * An alias of {@link notDeepStrictEqual}.
316
+ *
317
+ * **Legacy assertion mode**
318
+ *
319
+ * > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
320
+ *
321
+ * Tests for any deep inequality. Opposite of {@link deepEqual}.
322
+ *
323
+ * ```js
324
+ * import assert from 'assert';
325
+ *
326
+ * const obj1 = {
327
+ * a: {
328
+ * b: 1
329
+ * }
330
+ * };
331
+ * const obj2 = {
332
+ * a: {
333
+ * b: 2
334
+ * }
335
+ * };
336
+ * const obj3 = {
337
+ * a: {
338
+ * b: 1
339
+ * }
340
+ * };
341
+ * const obj4 = Object.create(obj1);
342
+ *
343
+ * assert.notDeepEqual(obj1, obj1);
344
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
345
+ *
346
+ * assert.notDeepEqual(obj1, obj2);
347
+ * // OK
348
+ *
349
+ * assert.notDeepEqual(obj1, obj3);
350
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
351
+ *
352
+ * assert.notDeepEqual(obj1, obj4);
353
+ * // OK
354
+ * ```
355
+ *
356
+ * If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
357
+ * error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
358
+ * instead of the `AssertionError`.
359
+ * @since v0.1.21
360
+ */
361
+ function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
362
+ /**
363
+ * Tests strict equality between the `actual` and `expected` parameters as
364
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
365
+ *
366
+ * ```js
367
+ * import assert from 'assert/strict';
368
+ *
369
+ * assert.strictEqual(1, 2);
370
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
371
+ * //
372
+ * // 1 !== 2
373
+ *
374
+ * assert.strictEqual(1, 1);
375
+ * // OK
376
+ *
377
+ * assert.strictEqual('Hello foobar', 'Hello World!');
378
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
379
+ * // + actual - expected
380
+ * //
381
+ * // + 'Hello foobar'
382
+ * // - 'Hello World!'
383
+ * // ^
384
+ *
385
+ * const apples = 1;
386
+ * const oranges = 2;
387
+ * assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
388
+ * // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
389
+ *
390
+ * assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
391
+ * // TypeError: Inputs are not identical
392
+ * ```
393
+ *
394
+ * If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
395
+ * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
396
+ * instead of the `AssertionError`.
397
+ * @since v0.1.21
398
+ */
399
+ function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
400
+ /**
401
+ * Tests strict inequality between the `actual` and `expected` parameters as
402
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
403
+ *
404
+ * ```js
405
+ * import assert from 'assert/strict';
406
+ *
407
+ * assert.notStrictEqual(1, 2);
408
+ * // OK
409
+ *
410
+ * assert.notStrictEqual(1, 1);
411
+ * // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
412
+ * //
413
+ * // 1
414
+ *
415
+ * assert.notStrictEqual(1, '1');
416
+ * // OK
417
+ * ```
418
+ *
419
+ * If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
420
+ * default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
421
+ * instead of the `AssertionError`.
422
+ * @since v0.1.21
423
+ */
424
+ function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
425
+ /**
426
+ * Tests for deep equality between the `actual` and `expected` parameters.
427
+ * "Deep" equality means that the enumerable "own" properties of child objects
428
+ * are recursively evaluated also by the following rules.
429
+ * @since v1.2.0
430
+ */
431
+ function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
432
+ /**
433
+ * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
434
+ *
435
+ * ```js
436
+ * import assert from 'assert/strict';
437
+ *
438
+ * assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
439
+ * // OK
440
+ * ```
441
+ *
442
+ * If the values are deeply and strictly equal, an `AssertionError` is thrown
443
+ * with a `message` property set equal to the value of the `message` parameter. If
444
+ * the `message` parameter is undefined, a default error message is assigned. If
445
+ * the `message` parameter is an instance of an `Error` then it will be thrown
446
+ * instead of the `AssertionError`.
447
+ * @since v1.2.0
448
+ */
449
+ function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
450
+ /**
451
+ * Expects the function `fn` to throw an error.
452
+ *
453
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
454
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
455
+ * a validation object where each property will be tested for strict deep equality,
456
+ * or an instance of error where each property will be tested for strict deep
457
+ * equality including the non-enumerable `message` and `name` properties. When
458
+ * using an object, it is also possible to use a regular expression, when
459
+ * validating against a string property. See below for examples.
460
+ *
461
+ * If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
462
+ * fails.
463
+ *
464
+ * Custom validation object/error instance:
465
+ *
466
+ * ```js
467
+ * import assert from 'assert/strict';
468
+ *
469
+ * const err = new TypeError('Wrong value');
470
+ * err.code = 404;
471
+ * err.foo = 'bar';
472
+ * err.info = {
473
+ * nested: true,
474
+ * baz: 'text'
475
+ * };
476
+ * err.reg = /abc/i;
477
+ *
478
+ * assert.throws(
479
+ * () => {
480
+ * throw err;
481
+ * },
482
+ * {
483
+ * name: 'TypeError',
484
+ * message: 'Wrong value',
485
+ * info: {
486
+ * nested: true,
487
+ * baz: 'text'
488
+ * }
489
+ * // Only properties on the validation object will be tested for.
490
+ * // Using nested objects requires all properties to be present. Otherwise
491
+ * // the validation is going to fail.
492
+ * }
493
+ * );
494
+ *
495
+ * // Using regular expressions to validate error properties:
496
+ * throws(
497
+ * () => {
498
+ * throw err;
499
+ * },
500
+ * {
501
+ * // The `name` and `message` properties are strings and using regular
502
+ * // expressions on those will match against the string. If they fail, an
503
+ * // error is thrown.
504
+ * name: /^TypeError$/,
505
+ * message: /Wrong/,
506
+ * foo: 'bar',
507
+ * info: {
508
+ * nested: true,
509
+ * // It is not possible to use regular expressions for nested properties!
510
+ * baz: 'text'
511
+ * },
512
+ * // The `reg` property contains a regular expression and only if the
513
+ * // validation object contains an identical regular expression, it is going
514
+ * // to pass.
515
+ * reg: /abc/i
516
+ * }
517
+ * );
518
+ *
519
+ * // Fails due to the different `message` and `name` properties:
520
+ * throws(
521
+ * () => {
522
+ * const otherErr = new Error('Not found');
523
+ * // Copy all enumerable properties from `err` to `otherErr`.
524
+ * for (const [key, value] of Object.entries(err)) {
525
+ * otherErr[key] = value;
526
+ * }
527
+ * throw otherErr;
528
+ * },
529
+ * // The error's `message` and `name` properties will also be checked when using
530
+ * // an error as validation object.
531
+ * err
532
+ * );
533
+ * ```
534
+ *
535
+ * Validate instanceof using constructor:
536
+ *
537
+ * ```js
538
+ * import assert from 'assert/strict';
539
+ *
540
+ * assert.throws(
541
+ * () => {
542
+ * throw new Error('Wrong value');
543
+ * },
544
+ * Error
545
+ * );
546
+ * ```
547
+ *
548
+ * Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
549
+ *
550
+ * Using a regular expression runs `.toString` on the error object, and will
551
+ * therefore also include the error name.
552
+ *
553
+ * ```js
554
+ * import assert from 'assert/strict';
555
+ *
556
+ * assert.throws(
557
+ * () => {
558
+ * throw new Error('Wrong value');
559
+ * },
560
+ * /^Error: Wrong value$/
561
+ * );
562
+ * ```
563
+ *
564
+ * Custom error validation:
565
+ *
566
+ * The function must return `true` to indicate all internal validations passed.
567
+ * It will otherwise fail with an `AssertionError`.
568
+ *
569
+ * ```js
570
+ * import assert from 'assert/strict';
571
+ *
572
+ * assert.throws(
573
+ * () => {
574
+ * throw new Error('Wrong value');
575
+ * },
576
+ * (err) => {
577
+ * assert(err instanceof Error);
578
+ * assert(/value/.test(err));
579
+ * // Avoid returning anything from validation functions besides `true`.
580
+ * // Otherwise, it's not clear what part of the validation failed. Instead,
581
+ * // throw an error about the specific validation that failed (as done in this
582
+ * // example) and add as much helpful debugging information to that error as
583
+ * // possible.
584
+ * return true;
585
+ * },
586
+ * 'unexpected error'
587
+ * );
588
+ * ```
589
+ *
590
+ * `error` cannot be a string. If a string is provided as the second
591
+ * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
592
+ * message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
593
+ * a string as the second argument gets considered:
594
+ *
595
+ * ```js
596
+ * import assert from 'assert/strict';
597
+ *
598
+ * function throwingFirst() {
599
+ * throw new Error('First');
600
+ * }
601
+ *
602
+ * function throwingSecond() {
603
+ * throw new Error('Second');
604
+ * }
605
+ *
606
+ * function notThrowing() {}
607
+ *
608
+ * // The second argument is a string and the input function threw an Error.
609
+ * // The first case will not throw as it does not match for the error message
610
+ * // thrown by the input function!
611
+ * assert.throws(throwingFirst, 'Second');
612
+ * // In the next example the message has no benefit over the message from the
613
+ * // error and since it is not clear if the user intended to actually match
614
+ * // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
615
+ * assert.throws(throwingSecond, 'Second');
616
+ * // TypeError [ERR_AMBIGUOUS_ARGUMENT]
617
+ *
618
+ * // The string is only used (as message) in case the function does not throw:
619
+ * assert.throws(notThrowing, 'Second');
620
+ * // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
621
+ *
622
+ * // If it was intended to match for the error message do this instead:
623
+ * // It does not throw because the error messages match.
624
+ * assert.throws(throwingSecond, /Second$/);
625
+ *
626
+ * // If the error message does not match, an AssertionError is thrown.
627
+ * assert.throws(throwingFirst, /Second$/);
628
+ * // AssertionError [ERR_ASSERTION]
629
+ * ```
630
+ *
631
+ * Due to the confusing error-prone notation, avoid a string as the second
632
+ * argument.
633
+ * @since v0.1.21
634
+ */
635
+ function throws(block: () => unknown, message?: string | Error): void;
636
+ function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
637
+ /**
638
+ * Asserts that the function `fn` does not throw an error.
639
+ *
640
+ * Using `assert.doesNotThrow()` is actually not useful because there
641
+ * is no benefit in catching an error and then rethrowing it. Instead, consider
642
+ * adding a comment next to the specific code path that should not throw and keep
643
+ * error messages as expressive as possible.
644
+ *
645
+ * When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
646
+ *
647
+ * If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
648
+ * different type, or if the `error` parameter is undefined, the error is
649
+ * propagated back to the caller.
650
+ *
651
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
652
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
653
+ * function. See {@link throws} for more details.
654
+ *
655
+ * The following, for instance, will throw the `TypeError` because there is no
656
+ * matching error type in the assertion:
657
+ *
658
+ * ```js
659
+ * import assert from 'assert/strict';
660
+ *
661
+ * assert.doesNotThrow(
662
+ * () => {
663
+ * throw new TypeError('Wrong value');
664
+ * },
665
+ * SyntaxError
666
+ * );
667
+ * ```
668
+ *
669
+ * However, the following will result in an `AssertionError` with the message
670
+ * 'Got unwanted exception...':
671
+ *
672
+ * ```js
673
+ * import assert from 'assert/strict';
674
+ *
675
+ * assert.doesNotThrow(
676
+ * () => {
677
+ * throw new TypeError('Wrong value');
678
+ * },
679
+ * TypeError
680
+ * );
681
+ * ```
682
+ *
683
+ * 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:
684
+ *
685
+ * ```js
686
+ * import assert from 'assert/strict';
687
+ *
688
+ * assert.doesNotThrow(
689
+ * () => {
690
+ * throw new TypeError('Wrong value');
691
+ * },
692
+ * /Wrong value/,
693
+ * 'Whoops'
694
+ * );
695
+ * // Throws: AssertionError: Got unwanted exception: Whoops
696
+ * ```
697
+ * @since v0.1.21
698
+ */
699
+ function doesNotThrow(block: () => unknown, message?: string | Error): void;
700
+ function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
701
+ /**
702
+ * Throws `value` if `value` is not `undefined` or `null`. This is useful when
703
+ * testing the `error` argument in callbacks. The stack trace contains all frames
704
+ * from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
705
+ *
706
+ * ```js
707
+ * import assert from 'assert/strict';
708
+ *
709
+ * assert.ifError(null);
710
+ * // OK
711
+ * assert.ifError(0);
712
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
713
+ * assert.ifError('error');
714
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
715
+ * assert.ifError(new Error());
716
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
717
+ *
718
+ * // Create some random error frames.
719
+ * let err;
720
+ * (function errorFrame() {
721
+ * err = new Error('test error');
722
+ * })();
723
+ *
724
+ * (function ifErrorFrame() {
725
+ * assert.ifError(err);
726
+ * })();
727
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
728
+ * // at ifErrorFrame
729
+ * // at errorFrame
730
+ * ```
731
+ * @since v0.1.97
732
+ */
733
+ function ifError(value: unknown): asserts value is null | undefined;
734
+ /**
735
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
736
+ * calls the function and awaits the returned promise to complete. It will then
737
+ * check that the promise is rejected.
738
+ *
739
+ * If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
740
+ * function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
741
+ * handler is skipped.
742
+ *
743
+ * Besides the async nature to await the completion behaves identically to {@link throws}.
744
+ *
745
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
746
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
747
+ * an object where each property will be tested for, or an instance of error where
748
+ * each property will be tested for including the non-enumerable `message` and`name` properties.
749
+ *
750
+ * If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
751
+ *
752
+ * ```js
753
+ * import assert from 'assert/strict';
754
+ *
755
+ * await assert.rejects(
756
+ * async () => {
757
+ * throw new TypeError('Wrong value');
758
+ * },
759
+ * {
760
+ * name: 'TypeError',
761
+ * message: 'Wrong value'
762
+ * }
763
+ * );
764
+ * ```
765
+ *
766
+ * ```js
767
+ * import assert from 'assert/strict';
768
+ *
769
+ * await assert.rejects(
770
+ * async () => {
771
+ * throw new TypeError('Wrong value');
772
+ * },
773
+ * (err) => {
774
+ * assert.strictEqual(err.name, 'TypeError');
775
+ * assert.strictEqual(err.message, 'Wrong value');
776
+ * return true;
777
+ * }
778
+ * );
779
+ * ```
780
+ *
781
+ * ```js
782
+ * import assert from 'assert/strict';
783
+ *
784
+ * assert.rejects(
785
+ * Promise.reject(new Error('Wrong value')),
786
+ * Error
787
+ * ).then(() => {
788
+ * // ...
789
+ * });
790
+ * ```
791
+ *
792
+ * `error` cannot be a string. If a string is provided as the second
793
+ * argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
794
+ * example in {@link throws} carefully if using a string as the second
795
+ * argument gets considered.
796
+ * @since v10.0.0
797
+ */
798
+ function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
799
+ function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
800
+ /**
801
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
802
+ * calls the function and awaits the returned promise to complete. It will then
803
+ * check that the promise is not rejected.
804
+ *
805
+ * If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
806
+ * the function does not return a promise, `assert.doesNotReject()` will return a
807
+ * rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
808
+ * the error handler is skipped.
809
+ *
810
+ * Using `assert.doesNotReject()` is actually not useful because there is little
811
+ * benefit in catching a rejection and then rejecting it again. Instead, consider
812
+ * adding a comment next to the specific code path that should not reject and keep
813
+ * error messages as expressive as possible.
814
+ *
815
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
816
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
817
+ * function. See {@link throws} for more details.
818
+ *
819
+ * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
820
+ *
821
+ * ```js
822
+ * import assert from 'assert/strict';
823
+ *
824
+ * await assert.doesNotReject(
825
+ * async () => {
826
+ * throw new TypeError('Wrong value');
827
+ * },
828
+ * SyntaxError
829
+ * );
830
+ * ```
831
+ *
832
+ * ```js
833
+ * import assert from 'assert/strict';
834
+ *
835
+ * assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
836
+ * .then(() => {
837
+ * // ...
838
+ * });
839
+ * ```
840
+ * @since v10.0.0
841
+ */
842
+ function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
843
+ function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
844
+ /**
845
+ * Expects the `string` input to match the regular expression.
846
+ *
847
+ * ```js
848
+ * import assert from 'assert/strict';
849
+ *
850
+ * assert.match('I will fail', /pass/);
851
+ * // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
852
+ *
853
+ * assert.match(123, /pass/);
854
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
855
+ *
856
+ * assert.match('I will pass', /pass/);
857
+ * // OK
858
+ * ```
859
+ *
860
+ * If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
861
+ * to the value of the `message` parameter. If the `message` parameter is
862
+ * undefined, a default error message is assigned. If the `message` parameter is an
863
+ * instance of an `Error` then it will be thrown instead of the `AssertionError`.
864
+ * @since v13.6.0, v12.16.0
865
+ */
866
+ function match(value: string, regExp: RegExp, message?: string | Error): void;
867
+ /**
868
+ * Expects the `string` input not to match the regular expression.
869
+ *
870
+ * ```js
871
+ * import assert from 'assert/strict';
872
+ *
873
+ * assert.doesNotMatch('I will fail', /fail/);
874
+ * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
875
+ *
876
+ * assert.doesNotMatch(123, /pass/);
877
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
878
+ *
879
+ * assert.doesNotMatch('I will pass', /different/);
880
+ * // OK
881
+ * ```
882
+ *
883
+ * If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
884
+ * to the value of the `message` parameter. If the `message` parameter is
885
+ * undefined, a default error message is assigned. If the `message` parameter is an
886
+ * instance of an `Error` then it will be thrown instead of the `AssertionError`.
887
+ * @since v13.6.0, v12.16.0
888
+ */
889
+ function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
890
+ const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
891
+ (value: unknown, message?: string | Error): asserts value;
892
+ equal: typeof strictEqual;
893
+ notEqual: typeof notStrictEqual;
894
+ deepEqual: typeof deepStrictEqual;
895
+ notDeepEqual: typeof notDeepStrictEqual;
896
+ // Mapped types and assertion functions are incompatible?
897
+ // TS2775: Assertions require every name in the call target
898
+ // to be declared with an explicit type annotation.
899
+ ok: typeof ok;
900
+ strictEqual: typeof strictEqual;
901
+ deepStrictEqual: typeof deepStrictEqual;
902
+ ifError: typeof ifError;
903
+ strict: typeof strict;
904
+ };
905
+ }
906
+ export = assert;
907
+ }
908
+ declare module 'node:assert' {
909
+ import assert = require('assert');
910
+ export = assert;
911
+ }