@types/node 16.3.3 → 16.4.3

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/util.d.ts CHANGED
@@ -1,6 +1,15 @@
1
+ /**
2
+ * The `util` module supports the needs of Node.js internal APIs. Many of the
3
+ * utilities are useful for application and module developers as well. To access
4
+ * it:
5
+ *
6
+ * ```js
7
+ * const util = require('util');
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/util.js)
10
+ */
1
11
  declare module 'util' {
2
12
  import * as types from 'node:util/types';
3
-
4
13
  export interface InspectOptions {
5
14
  /**
6
15
  * If set to `true`, getters are going to be
@@ -41,24 +50,257 @@ declare module 'util' {
41
50
  compact?: boolean | number | undefined;
42
51
  sorted?: boolean | ((a: string, b: string) => number) | undefined;
43
52
  }
44
-
45
53
  export type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
46
54
  export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
47
55
  export interface InspectOptionsStylized extends InspectOptions {
48
56
  stylize(text: string, styleType: Style): string;
49
57
  }
58
+ /**
59
+ * The `util.format()` method returns a formatted string using the first argument
60
+ * as a `printf`\-like format string which can contain zero or more format
61
+ * specifiers. Each specifier is replaced with the converted value from the
62
+ * corresponding argument. Supported specifiers are:
63
+ *
64
+ * If a specifier does not have a corresponding argument, it is not replaced:
65
+ *
66
+ * ```js
67
+ * util.format('%s:%s', 'foo');
68
+ * // Returns: 'foo:%s'
69
+ * ```
70
+ *
71
+ * Values that are not part of the format string are formatted using`util.inspect()` if their type is not `string`.
72
+ *
73
+ * If there are more arguments passed to the `util.format()` method than the
74
+ * number of specifiers, the extra arguments are concatenated to the returned
75
+ * string, separated by spaces:
76
+ *
77
+ * ```js
78
+ * util.format('%s:%s', 'foo', 'bar', 'baz');
79
+ * // Returns: 'foo:bar baz'
80
+ * ```
81
+ *
82
+ * If the first argument does not contain a valid format specifier, `util.format()`returns a string that is the concatenation of all arguments separated by spaces:
83
+ *
84
+ * ```js
85
+ * util.format(1, 2, 3);
86
+ * // Returns: '1 2 3'
87
+ * ```
88
+ *
89
+ * If only one argument is passed to `util.format()`, it is returned as it is
90
+ * without any formatting:
91
+ *
92
+ * ```js
93
+ * util.format('%% %s');
94
+ * // Returns: '%% %s'
95
+ * ```
96
+ *
97
+ * `util.format()` is a synchronous method that is intended as a debugging tool.
98
+ * Some input values can have a significant performance overhead that can block the
99
+ * event loop. Use this function with care and never in a hot code path.
100
+ * @since v0.5.3
101
+ * @param format A `printf`-like format string.
102
+ */
50
103
  export function format(format?: any, ...param: any[]): string;
104
+ /**
105
+ * This function is identical to {@link format}, except in that it takes
106
+ * an `inspectOptions` argument which specifies options that are passed along to {@link inspect}.
107
+ *
108
+ * ```js
109
+ * util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 });
110
+ * // Returns 'See object { foo: 42 }', where `42` is colored as a number
111
+ * // when printed to a terminal.
112
+ * ```
113
+ * @since v10.0.0
114
+ */
51
115
  export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
116
+ /**
117
+ * Returns a Map of all system error codes available from the Node.js API.
118
+ * The mapping between error codes and error names is platform-dependent.
119
+ * See `Common System Errors` for the names of common errors.
120
+ *
121
+ * ```js
122
+ * fs.access('file/that/does/not/exist', (err) => {
123
+ * const errorMap = util.getSystemErrorMap();
124
+ * const name = errorMap.get(err.errno);
125
+ * console.error(name); // ENOENT
126
+ * });
127
+ * ```
128
+ * @since v16.0.0
129
+ */
52
130
  export function getSystemErrorMap(): Map<number, [string, string]>;
53
-
54
- /** @deprecated since v0.11.3 - use a third party module instead. */
131
+ /**
132
+ * The `util.log()` method prints the given `string` to `stdout` with an included
133
+ * timestamp.
134
+ *
135
+ * ```js
136
+ * const util = require('util');
137
+ *
138
+ * util.log('Timestamped message.');
139
+ * ```
140
+ * @since v0.3.0
141
+ * @deprecated Since v6.0.0 - Use a third party module instead.
142
+ */
55
143
  export function log(string: string): void;
144
+ /**
145
+ * The `util.inspect()` method returns a string representation of `object` that is
146
+ * intended for debugging. The output of `util.inspect` may change at any time
147
+ * and should not be depended upon programmatically. Additional `options` may be
148
+ * passed that alter the result.`util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
149
+ * an identifiable tag for an inspected value.
150
+ *
151
+ * ```js
152
+ * class Foo {
153
+ * get [Symbol.toStringTag]() {
154
+ * return 'bar';
155
+ * }
156
+ * }
157
+ *
158
+ * class Bar {}
159
+ *
160
+ * const baz = Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } });
161
+ *
162
+ * util.inspect(new Foo()); // 'Foo [bar] {}'
163
+ * util.inspect(new Bar()); // 'Bar {}'
164
+ * util.inspect(baz); // '[foo] {}'
165
+ * ```
166
+ *
167
+ * Circular references point to their anchor by using a reference index:
168
+ *
169
+ * ```js
170
+ * const { inspect } = require('util');
171
+ *
172
+ * const obj = {};
173
+ * obj.a = [obj];
174
+ * obj.b = {};
175
+ * obj.b.inner = obj.b;
176
+ * obj.b.obj = obj;
177
+ *
178
+ * console.log(inspect(obj));
179
+ * // <ref *1> {
180
+ * // a: [ [Circular *1] ],
181
+ * // b: <ref *2> { inner: [Circular *2], obj: [Circular *1] }
182
+ * // }
183
+ * ```
184
+ *
185
+ * The following example inspects all properties of the `util` object:
186
+ *
187
+ * ```js
188
+ * const util = require('util');
189
+ *
190
+ * console.log(util.inspect(util, { showHidden: true, depth: null }));
191
+ * ```
192
+ *
193
+ * The following example highlights the effect of the `compact` option:
194
+ *
195
+ * ```js
196
+ * const util = require('util');
197
+ *
198
+ * const o = {
199
+ * a: [1, 2, [[
200
+ * 'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' +
201
+ * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
202
+ * 'test',
203
+ * 'foo']], 4],
204
+ * b: new Map([['za', 1], ['zb', 'test']])
205
+ * };
206
+ * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
207
+ *
208
+ * // { a:
209
+ * // [ 1,
210
+ * // 2,
211
+ * // [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line
212
+ * // 'test',
213
+ * // 'foo' ] ],
214
+ * // 4 ],
215
+ * // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
216
+ *
217
+ * // Setting `compact` to false or an integer creates more reader friendly output.
218
+ * console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
219
+ *
220
+ * // {
221
+ * // a: [
222
+ * // 1,
223
+ * // 2,
224
+ * // [
225
+ * // [
226
+ * // 'Lorem ipsum dolor sit amet,\n' +
227
+ * // 'consectetur adipiscing elit, sed do eiusmod \n' +
228
+ * // 'tempor incididunt ut labore et dolore magna aliqua.',
229
+ * // 'test',
230
+ * // 'foo'
231
+ * // ]
232
+ * // ],
233
+ * // 4
234
+ * // ],
235
+ * // b: Map(2) {
236
+ * // 'za' => 1,
237
+ * // 'zb' => 'test'
238
+ * // }
239
+ * // }
240
+ *
241
+ * // Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a
242
+ * // single line.
243
+ * ```
244
+ *
245
+ * The `showHidden` option allows [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and
246
+ * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be
247
+ * inspected. If there are more entries than `maxArrayLength`, there is no
248
+ * guarantee which entries are displayed. That means retrieving the same[`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries twice may
249
+ * result in different output. Furthermore, entries
250
+ * with no remaining strong references may be garbage collected at any time.
251
+ *
252
+ * ```js
253
+ * const { inspect } = require('util');
254
+ *
255
+ * const obj = { a: 1 };
256
+ * const obj2 = { b: 2 };
257
+ * const weakSet = new WeakSet([obj, obj2]);
258
+ *
259
+ * console.log(inspect(weakSet, { showHidden: true }));
260
+ * // WeakSet { { a: 1 }, { b: 2 } }
261
+ * ```
262
+ *
263
+ * The `sorted` option ensures that an object's property insertion order does not
264
+ * impact the result of `util.inspect()`.
265
+ *
266
+ * ```js
267
+ * const { inspect } = require('util');
268
+ * const assert = require('assert');
269
+ *
270
+ * const o1 = {
271
+ * b: [2, 3, 1],
272
+ * a: '`a` comes before `b`',
273
+ * c: new Set([2, 3, 1])
274
+ * };
275
+ * console.log(inspect(o1, { sorted: true }));
276
+ * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } }
277
+ * console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) }));
278
+ * // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' }
279
+ *
280
+ * const o2 = {
281
+ * c: new Set([2, 1, 3]),
282
+ * a: '`a` comes before `b`',
283
+ * b: [2, 3, 1]
284
+ * };
285
+ * assert.strict.equal(
286
+ * inspect(o1, { sorted: true }),
287
+ * inspect(o2, { sorted: true })
288
+ * );
289
+ * ```
290
+ *
291
+ * `util.inspect()` is a synchronous method intended for debugging. Its maximum
292
+ * output length is approximately 128 MB. Inputs that result in longer output will
293
+ * be truncated.
294
+ * @since v0.3.0
295
+ * @param object Any JavaScript primitive or `Object`.
296
+ * @return The representation of `object`.
297
+ */
56
298
  export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
57
299
  export function inspect(object: any, options: InspectOptions): string;
58
300
  export namespace inspect {
59
301
  let colors: NodeJS.Dict<[number, number]>;
60
302
  let styles: {
61
- [K in Style]: string
303
+ [K in Style]: string;
62
304
  };
63
305
  let defaultOptions: InspectOptions;
64
306
  /**
@@ -67,41 +309,524 @@ declare module 'util' {
67
309
  let replDefaults: InspectOptions;
68
310
  const custom: unique symbol;
69
311
  }
70
- /** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
312
+ /**
313
+ * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
314
+ *
315
+ * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
316
+ *
317
+ * ```js
318
+ * const util = require('util');
319
+ *
320
+ * util.isArray([]);
321
+ * // Returns: true
322
+ * util.isArray(new Array());
323
+ * // Returns: true
324
+ * util.isArray({});
325
+ * // Returns: false
326
+ * ```
327
+ * @since v0.6.0
328
+ * @deprecated Since v4.0.0 - Use `isArray` instead.
329
+ */
71
330
  export function isArray(object: unknown): object is unknown[];
72
- /** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
331
+ /**
332
+ * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
333
+ *
334
+ * ```js
335
+ * const util = require('util');
336
+ *
337
+ * util.isRegExp(/some regexp/);
338
+ * // Returns: true
339
+ * util.isRegExp(new RegExp('another regexp'));
340
+ * // Returns: true
341
+ * util.isRegExp({});
342
+ * // Returns: false
343
+ * ```
344
+ * @since v0.6.0
345
+ * @deprecated Since v4.0.0 - Deprecated
346
+ */
73
347
  export function isRegExp(object: unknown): object is RegExp;
74
- /** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
348
+ /**
349
+ * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
350
+ *
351
+ * ```js
352
+ * const util = require('util');
353
+ *
354
+ * util.isDate(new Date());
355
+ * // Returns: true
356
+ * util.isDate(Date());
357
+ * // false (without 'new' returns a String)
358
+ * util.isDate({});
359
+ * // Returns: false
360
+ * ```
361
+ * @since v0.6.0
362
+ * @deprecated Since v4.0.0 - Use {@link types.isDate} instead.
363
+ */
75
364
  export function isDate(object: unknown): object is Date;
76
- /** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
365
+ /**
366
+ * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`.
367
+ *
368
+ * ```js
369
+ * const util = require('util');
370
+ *
371
+ * util.isError(new Error());
372
+ * // Returns: true
373
+ * util.isError(new TypeError());
374
+ * // Returns: true
375
+ * util.isError({ name: 'Error', message: 'an error occurred' });
376
+ * // Returns: false
377
+ * ```
378
+ *
379
+ * This method relies on `Object.prototype.toString()` behavior. It is
380
+ * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`.
381
+ *
382
+ * ```js
383
+ * const util = require('util');
384
+ * const obj = { name: 'Error', message: 'an error occurred' };
385
+ *
386
+ * util.isError(obj);
387
+ * // Returns: false
388
+ * obj[Symbol.toStringTag] = 'Error';
389
+ * util.isError(obj);
390
+ * // Returns: true
391
+ * ```
392
+ * @since v0.6.0
393
+ * @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead.
394
+ */
77
395
  export function isError(object: unknown): object is Error;
396
+ /**
397
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and`extends` keywords to get language level inheritance support. Also note
398
+ * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
399
+ *
400
+ * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
401
+ * prototype of `constructor` will be set to a new object created from`superConstructor`.
402
+ *
403
+ * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
404
+ * As an additional convenience, `superConstructor` will be accessible
405
+ * through the `constructor.super_` property.
406
+ *
407
+ * ```js
408
+ * const util = require('util');
409
+ * const EventEmitter = require('events');
410
+ *
411
+ * function MyStream() {
412
+ * EventEmitter.call(this);
413
+ * }
414
+ *
415
+ * util.inherits(MyStream, EventEmitter);
416
+ *
417
+ * MyStream.prototype.write = function(data) {
418
+ * this.emit('data', data);
419
+ * };
420
+ *
421
+ * const stream = new MyStream();
422
+ *
423
+ * console.log(stream instanceof EventEmitter); // true
424
+ * console.log(MyStream.super_ === EventEmitter); // true
425
+ *
426
+ * stream.on('data', (data) => {
427
+ * console.log(`Received data: "${data}"`);
428
+ * });
429
+ * stream.write('It works!'); // Received data: "It works!"
430
+ * ```
431
+ *
432
+ * ES6 example using `class` and `extends`:
433
+ *
434
+ * ```js
435
+ * const EventEmitter = require('events');
436
+ *
437
+ * class MyStream extends EventEmitter {
438
+ * write(data) {
439
+ * this.emit('data', data);
440
+ * }
441
+ * }
442
+ *
443
+ * const stream = new MyStream();
444
+ *
445
+ * stream.on('data', (data) => {
446
+ * console.log(`Received data: "${data}"`);
447
+ * });
448
+ * stream.write('With ES6');
449
+ * ```
450
+ * @since v0.3.0
451
+ * @deprecated Legacy: Use ES2015 class syntax and `extends` keyword instead.
452
+ */
78
453
  export function inherits(constructor: unknown, superConstructor: unknown): void;
454
+ /**
455
+ * The `util.debuglog()` method is used to create a function that conditionally
456
+ * writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`environment variable. If the `section` name appears within the value of that
457
+ * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
458
+ *
459
+ * ```js
460
+ * const util = require('util');
461
+ * const debuglog = util.debuglog('foo');
462
+ *
463
+ * debuglog('hello from foo [%d]', 123);
464
+ * ```
465
+ *
466
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then
467
+ * it will output something like:
468
+ *
469
+ * ```console
470
+ * FOO 3245: hello from foo [123]
471
+ * ```
472
+ *
473
+ * where `3245` is the process id. If it is not run with that
474
+ * environment variable set, then it will not print anything.
475
+ *
476
+ * The `section` supports wildcard also:
477
+ *
478
+ * ```js
479
+ * const util = require('util');
480
+ * const debuglog = util.debuglog('foo-bar');
481
+ *
482
+ * debuglog('hi there, it\'s foo-bar [%d]', 2333);
483
+ * ```
484
+ *
485
+ * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
486
+ * something like:
487
+ *
488
+ * ```console
489
+ * FOO-BAR 3257: hi there, it's foo-bar [2333]
490
+ * ```
491
+ *
492
+ * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`environment variable: `NODE_DEBUG=fs,net,tls`.
493
+ *
494
+ * The optional `callback` argument can be used to replace the logging function
495
+ * with a different function that doesn't have any initialization or
496
+ * unnecessary wrapping.
497
+ *
498
+ * ```js
499
+ * const util = require('util');
500
+ * let debuglog = util.debuglog('internals', (debug) => {
501
+ * // Replace with a logging function that optimizes out
502
+ * // testing if the section is enabled
503
+ * debuglog = debug;
504
+ * });
505
+ * ```
506
+ * @since v0.11.3
507
+ * @param section A string identifying the portion of the application for which the `debuglog` function is being created.
508
+ * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function.
509
+ * @return The logging function
510
+ */
79
511
  export function debuglog(key: string): (msg: string, ...param: unknown[]) => void;
80
- /** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
512
+ /**
513
+ * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
514
+ *
515
+ * ```js
516
+ * const util = require('util');
517
+ *
518
+ * util.isBoolean(1);
519
+ * // Returns: false
520
+ * util.isBoolean(0);
521
+ * // Returns: false
522
+ * util.isBoolean(false);
523
+ * // Returns: true
524
+ * ```
525
+ * @since v0.11.5
526
+ * @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead.
527
+ */
81
528
  export function isBoolean(object: unknown): object is boolean;
82
- /** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
529
+ /**
530
+ * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
531
+ *
532
+ * ```js
533
+ * const util = require('util');
534
+ *
535
+ * util.isBuffer({ length: 0 });
536
+ * // Returns: false
537
+ * util.isBuffer([]);
538
+ * // Returns: false
539
+ * util.isBuffer(Buffer.from('hello world'));
540
+ * // Returns: true
541
+ * ```
542
+ * @since v0.11.5
543
+ * @deprecated Since v4.0.0 - Use `isBuffer` instead.
544
+ */
83
545
  export function isBuffer(object: unknown): object is Buffer;
84
- /** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
546
+ /**
547
+ * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`.
548
+ *
549
+ * ```js
550
+ * const util = require('util');
551
+ *
552
+ * function Foo() {}
553
+ * const Bar = () => {};
554
+ *
555
+ * util.isFunction({});
556
+ * // Returns: false
557
+ * util.isFunction(Foo);
558
+ * // Returns: true
559
+ * util.isFunction(Bar);
560
+ * // Returns: true
561
+ * ```
562
+ * @since v0.11.5
563
+ * @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead.
564
+ */
85
565
  export function isFunction(object: unknown): boolean;
86
- /** @deprecated since v4.0.0 - use `value === null` instead. */
566
+ /**
567
+ * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
568
+ *
569
+ * ```js
570
+ * const util = require('util');
571
+ *
572
+ * util.isNull(0);
573
+ * // Returns: false
574
+ * util.isNull(undefined);
575
+ * // Returns: false
576
+ * util.isNull(null);
577
+ * // Returns: true
578
+ * ```
579
+ * @since v0.11.5
580
+ * @deprecated Since v4.0.0 - Use `value === null` instead.
581
+ */
87
582
  export function isNull(object: unknown): object is null;
88
- /** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
583
+ /**
584
+ * Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
585
+ * returns `false`.
586
+ *
587
+ * ```js
588
+ * const util = require('util');
589
+ *
590
+ * util.isNullOrUndefined(0);
591
+ * // Returns: false
592
+ * util.isNullOrUndefined(undefined);
593
+ * // Returns: true
594
+ * util.isNullOrUndefined(null);
595
+ * // Returns: true
596
+ * ```
597
+ * @since v0.11.5
598
+ * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
599
+ */
89
600
  export function isNullOrUndefined(object: unknown): object is null | undefined;
90
- /** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
601
+ /**
602
+ * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
603
+ *
604
+ * ```js
605
+ * const util = require('util');
606
+ *
607
+ * util.isNumber(false);
608
+ * // Returns: false
609
+ * util.isNumber(Infinity);
610
+ * // Returns: true
611
+ * util.isNumber(0);
612
+ * // Returns: true
613
+ * util.isNumber(NaN);
614
+ * // Returns: true
615
+ * ```
616
+ * @since v0.11.5
617
+ * @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead.
618
+ */
91
619
  export function isNumber(object: unknown): object is number;
92
- /** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
620
+ /**
621
+ * Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript).
622
+ * Otherwise, returns `false`.
623
+ *
624
+ * ```js
625
+ * const util = require('util');
626
+ *
627
+ * util.isObject(5);
628
+ * // Returns: false
629
+ * util.isObject(null);
630
+ * // Returns: false
631
+ * util.isObject({});
632
+ * // Returns: true
633
+ * util.isObject(() => {});
634
+ * // Returns: false
635
+ * ```
636
+ * @since v0.11.5
637
+ * @deprecated Since v4.0.0 - Deprecated: Use `value !== null && typeof value === 'object'` instead.
638
+ */
93
639
  export function isObject(object: unknown): boolean;
94
- /** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
640
+ /**
641
+ * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
642
+ *
643
+ * ```js
644
+ * const util = require('util');
645
+ *
646
+ * util.isPrimitive(5);
647
+ * // Returns: true
648
+ * util.isPrimitive('foo');
649
+ * // Returns: true
650
+ * util.isPrimitive(false);
651
+ * // Returns: true
652
+ * util.isPrimitive(null);
653
+ * // Returns: true
654
+ * util.isPrimitive(undefined);
655
+ * // Returns: true
656
+ * util.isPrimitive({});
657
+ * // Returns: false
658
+ * util.isPrimitive(() => {});
659
+ * // Returns: false
660
+ * util.isPrimitive(/^$/);
661
+ * // Returns: false
662
+ * util.isPrimitive(new Date());
663
+ * // Returns: false
664
+ * ```
665
+ * @since v0.11.5
666
+ * @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead.
667
+ */
95
668
  export function isPrimitive(object: unknown): boolean;
96
- /** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
669
+ /**
670
+ * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
671
+ *
672
+ * ```js
673
+ * const util = require('util');
674
+ *
675
+ * util.isString('');
676
+ * // Returns: true
677
+ * util.isString('foo');
678
+ * // Returns: true
679
+ * util.isString(String('foo'));
680
+ * // Returns: true
681
+ * util.isString(5);
682
+ * // Returns: false
683
+ * ```
684
+ * @since v0.11.5
685
+ * @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead.
686
+ */
97
687
  export function isString(object: unknown): object is string;
98
- /** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
688
+ /**
689
+ * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
690
+ *
691
+ * ```js
692
+ * const util = require('util');
693
+ *
694
+ * util.isSymbol(5);
695
+ * // Returns: false
696
+ * util.isSymbol('foo');
697
+ * // Returns: false
698
+ * util.isSymbol(Symbol('foo'));
699
+ * // Returns: true
700
+ * ```
701
+ * @since v0.11.5
702
+ * @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead.
703
+ */
99
704
  export function isSymbol(object: unknown): object is symbol;
100
- /** @deprecated since v4.0.0 - use `value === undefined` instead. */
705
+ /**
706
+ * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
707
+ *
708
+ * ```js
709
+ * const util = require('util');
710
+ *
711
+ * const foo = undefined;
712
+ * util.isUndefined(5);
713
+ * // Returns: false
714
+ * util.isUndefined(foo);
715
+ * // Returns: true
716
+ * util.isUndefined(null);
717
+ * // Returns: false
718
+ * ```
719
+ * @since v0.11.5
720
+ * @deprecated Since v4.0.0 - Use `value === undefined` instead.
721
+ */
101
722
  export function isUndefined(object: unknown): object is undefined;
723
+ /**
724
+ * The `util.deprecate()` method wraps `fn` (which may be a function or class) in
725
+ * such a way that it is marked as deprecated.
726
+ *
727
+ * ```js
728
+ * const util = require('util');
729
+ *
730
+ * exports.obsoleteFunction = util.deprecate(() => {
731
+ * // Do something here.
732
+ * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
733
+ * ```
734
+ *
735
+ * When called, `util.deprecate()` will return a function that will emit a`DeprecationWarning` using the `'warning'` event. The warning will
736
+ * be emitted and printed to `stderr` the first time the returned function is
737
+ * called. After the warning is emitted, the wrapped function is called without
738
+ * emitting a warning.
739
+ *
740
+ * If the same optional `code` is supplied in multiple calls to `util.deprecate()`,
741
+ * the warning will be emitted only once for that `code`.
742
+ *
743
+ * ```js
744
+ * const util = require('util');
745
+ *
746
+ * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
747
+ * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
748
+ * fn1(); // Emits a deprecation warning with code DEP0001
749
+ * fn2(); // Does not emit a deprecation warning because it has the same code
750
+ * ```
751
+ *
752
+ * If either the `--no-deprecation` or `--no-warnings` command-line flags are
753
+ * used, or if the `process.noDeprecation` property is set to `true`_prior_ to
754
+ * the first deprecation warning, the `util.deprecate()` method does nothing.
755
+ *
756
+ * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
757
+ * or the `process.traceDeprecation` property is set to `true`, a warning and a
758
+ * stack trace are printed to `stderr` the first time the deprecated function is
759
+ * called.
760
+ *
761
+ * If the `--throw-deprecation` command-line flag is set, or the`process.throwDeprecation` property is set to `true`, then an exception will be
762
+ * thrown when the deprecated function is called.
763
+ *
764
+ * The `--throw-deprecation` command-line flag and `process.throwDeprecation`property take precedence over `--trace-deprecation` and`process.traceDeprecation`.
765
+ * @since v0.8.0
766
+ * @param fn The function that is being deprecated.
767
+ * @param msg A warning message to display when the deprecated function is invoked.
768
+ * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
769
+ * @return The deprecated function wrapped to emit a warning.
770
+ */
102
771
  export function deprecate<T extends Function>(fn: T, message: string, code?: string): T;
772
+ /**
773
+ * Returns `true` if there is deep strict equality between `val1` and `val2`.
774
+ * Otherwise, returns `false`.
775
+ *
776
+ * See `assert.deepStrictEqual()` for more information about deep strict
777
+ * equality.
778
+ * @since v9.0.0
779
+ */
103
780
  export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
104
-
781
+ /**
782
+ * Takes an `async` function (or a function that returns a `Promise`) and returns a
783
+ * function following the error-first callback style, i.e. taking
784
+ * an `(err, value) => ...` callback as the last argument. In the callback, the
785
+ * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value.
786
+ *
787
+ * ```js
788
+ * const util = require('util');
789
+ *
790
+ * async function fn() {
791
+ * return 'hello world';
792
+ * }
793
+ * const callbackFunction = util.callbackify(fn);
794
+ *
795
+ * callbackFunction((err, ret) => {
796
+ * if (err) throw err;
797
+ * console.log(ret);
798
+ * });
799
+ * ```
800
+ *
801
+ * Will print:
802
+ *
803
+ * ```text
804
+ * hello world
805
+ * ```
806
+ *
807
+ * The callback is executed asynchronously, and will have a limited stack trace.
808
+ * If the callback throws, the process will emit an `'uncaughtException'` event, and if not handled will exit.
809
+ *
810
+ * Since `null` has a special meaning as the first argument to a callback, if a
811
+ * wrapped function rejects a `Promise` with a falsy value as a reason, the value
812
+ * is wrapped in an `Error` with the original value stored in a field named`reason`.
813
+ *
814
+ * ```js
815
+ * function fn() {
816
+ * return Promise.reject(null);
817
+ * }
818
+ * const callbackFunction = util.callbackify(fn);
819
+ *
820
+ * callbackFunction((err, ret) => {
821
+ * // When the Promise was rejected with `null` it is wrapped with an Error and
822
+ * // the original value is stored in `reason`.
823
+ * err &#x26;&#x26; err.hasOwnProperty('reason') &#x26;&#x26; err.reason === null; // true
824
+ * });
825
+ * ```
826
+ * @since v8.2.0
827
+ * @param original An `async` function
828
+ * @return a callback style function
829
+ */
105
830
  export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
106
831
  export function callbackify<TResult>(fn: () => Promise<TResult>): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
107
832
  export function callbackify<T1>(fn: (arg1: T1) => Promise<void>): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
@@ -110,33 +835,100 @@ declare module 'util' {
110
835
  export function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
111
836
  export function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
112
837
  export function callbackify<T1, T2, T3, TResult>(
113
- fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
114
- export function callbackify<T1, T2, T3, T4>(
115
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
116
- export function callbackify<T1, T2, T3, T4, TResult>(
117
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
118
- export function callbackify<T1, T2, T3, T4, T5>(
119
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
120
- export function callbackify<T1, T2, T3, T4, T5, TResult>(
121
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
838
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>
839
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
840
+ export function callbackify<T1, T2, T3, T4>(
841
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>
842
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
843
+ export function callbackify<T1, T2, T3, T4, TResult>(
844
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>
845
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
846
+ export function callbackify<T1, T2, T3, T4, T5>(
847
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>
848
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
849
+ export function callbackify<T1, T2, T3, T4, T5, TResult>(
850
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>
122
851
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
123
852
  export function callbackify<T1, T2, T3, T4, T5, T6>(
124
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
853
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>
125
854
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
126
855
  export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
127
856
  fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>
128
857
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
129
-
130
858
  export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
131
859
  __promisify__: TCustom;
132
860
  }
133
-
134
861
  export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
135
862
  [promisify.custom]: TCustom;
136
863
  }
137
-
138
864
  export type CustomPromisify<TCustom extends Function> = CustomPromisifySymbol<TCustom> | CustomPromisifyLegacy<TCustom>;
139
-
865
+ /**
866
+ * Takes a function following the common error-first callback style, i.e. taking
867
+ * an `(err, value) => ...` callback as the last argument, and returns a version
868
+ * that returns promises.
869
+ *
870
+ * ```js
871
+ * const util = require('util');
872
+ * const fs = require('fs');
873
+ *
874
+ * const stat = util.promisify(fs.stat);
875
+ * stat('.').then((stats) => {
876
+ * // Do something with `stats`
877
+ * }).catch((error) => {
878
+ * // Handle the error.
879
+ * });
880
+ * ```
881
+ *
882
+ * Or, equivalently using `async function`s:
883
+ *
884
+ * ```js
885
+ * const util = require('util');
886
+ * const fs = require('fs');
887
+ *
888
+ * const stat = util.promisify(fs.stat);
889
+ *
890
+ * async function callStat() {
891
+ * const stats = await stat('.');
892
+ * console.log(`This directory is owned by ${stats.uid}`);
893
+ * }
894
+ * ```
895
+ *
896
+ * If there is an `original[util.promisify.custom]` property present, `promisify`will return its value, see `Custom promisified functions`.
897
+ *
898
+ * `promisify()` assumes that `original` is a function taking a callback as its
899
+ * final argument in all cases. If `original` is not a function, `promisify()`will throw an error. If `original` is a function but its last argument is not
900
+ * an error-first callback, it will still be passed an error-first
901
+ * callback as its last argument.
902
+ *
903
+ * Using `promisify()` on class methods or other methods that use `this` may not
904
+ * work as expected unless handled specially:
905
+ *
906
+ * ```js
907
+ * const util = require('util');
908
+ *
909
+ * class Foo {
910
+ * constructor() {
911
+ * this.a = 42;
912
+ * }
913
+ *
914
+ * bar(callback) {
915
+ * callback(null, this.a);
916
+ * }
917
+ * }
918
+ *
919
+ * const foo = new Foo();
920
+ *
921
+ * const naiveBar = util.promisify(foo.bar);
922
+ * // TypeError: Cannot read property 'a' of undefined
923
+ * // naiveBar().then(a => console.log(a));
924
+ *
925
+ * naiveBar.call(foo).then((a) => console.log(a)); // '42'
926
+ *
927
+ * const bindBar = naiveBar.bind(foo);
928
+ * bindBar().then((a) => console.log(a)); // '42'
929
+ * ```
930
+ * @since v8.0.0
931
+ */
140
932
  export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
141
933
  export function promisify<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise<TResult>;
142
934
  export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
@@ -144,125 +936,617 @@ declare module 'util' {
144
936
  export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
145
937
  export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
146
938
  export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
147
- export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void):
148
- (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
939
+ export function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
149
940
  export function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
150
941
  export function promisify<T1, T2, T3, T4, TResult>(
151
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
942
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void
152
943
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
153
- export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void):
154
- (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
155
- export function promisify<T1, T2, T3, T4, T5, TResult>(
156
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
944
+ export function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
945
+ export function promisify<T1, T2, T3, T4, T5, TResult>(
946
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void
157
947
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
158
948
  export function promisify<T1, T2, T3, T4, T5>(
159
- fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
949
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void
160
950
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
161
951
  export function promisify(fn: Function): Function;
162
952
  export namespace promisify {
163
953
  const custom: unique symbol;
164
954
  }
955
+ /**
956
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/)`TextDecoder` API.
957
+ *
958
+ * ```js
959
+ * const decoder = new TextDecoder('shift_jis');
960
+ * let string = '';
961
+ * let buffer;
962
+ * while (buffer = getNextChunkSomehow()) {
963
+ * string += decoder.decode(buffer, { stream: true });
964
+ * }
965
+ * string += decoder.decode(); // end-of-stream
966
+ * ```
967
+ * @since v8.3.0
968
+ */
165
969
  export class TextDecoder {
970
+ /**
971
+ * The encoding supported by the `TextDecoder` instance.
972
+ */
166
973
  readonly encoding: string;
974
+ /**
975
+ * The value will be `true` if decoding errors result in a `TypeError` being
976
+ * thrown.
977
+ */
167
978
  readonly fatal: boolean;
979
+ /**
980
+ * The value will be `true` if the decoding result will include the byte order
981
+ * mark.
982
+ */
168
983
  readonly ignoreBOM: boolean;
169
984
  constructor(
170
- encoding?: string,
171
- options?: { fatal?: boolean | undefined; ignoreBOM?: boolean | undefined }
985
+ encoding?: string,
986
+ options?: {
987
+ fatal?: boolean | undefined;
988
+ ignoreBOM?: boolean | undefined;
989
+ }
172
990
  );
991
+ /**
992
+ * Decodes the `input` and returns a string. If `options.stream` is `true`, any
993
+ * incomplete byte sequences occurring at the end of the `input` are buffered
994
+ * internally and emitted after the next call to `textDecoder.decode()`.
995
+ *
996
+ * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown.
997
+ * @param input An `ArrayBuffer`, `DataView` or `TypedArray` instance containing the encoded data.
998
+ */
173
999
  decode(
174
- input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
175
- options?: { stream?: boolean | undefined }
1000
+ input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
1001
+ options?: {
1002
+ stream?: boolean | undefined;
1003
+ }
176
1004
  ): string;
177
1005
  }
178
-
179
1006
  export interface EncodeIntoResult {
180
1007
  /**
181
1008
  * The read Unicode code units of input.
182
1009
  */
183
-
184
1010
  read: number;
185
1011
  /**
186
1012
  * The written UTF-8 bytes of output.
187
1013
  */
188
1014
  written: number;
189
1015
  }
190
-
191
1016
  export { types };
192
-
1017
+ /**
1018
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/)`TextEncoder` API. All
1019
+ * instances of `TextEncoder` only support UTF-8 encoding.
1020
+ *
1021
+ * ```js
1022
+ * const encoder = new TextEncoder();
1023
+ * const uint8array = encoder.encode('this is some data');
1024
+ * ```
1025
+ *
1026
+ * The `TextEncoder` class is also available on the global object.
1027
+ * @since v8.3.0
1028
+ */
193
1029
  export class TextEncoder {
1030
+ /**
1031
+ * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
1032
+ */
194
1033
  readonly encoding: string;
1034
+ /**
1035
+ * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
1036
+ * encoded bytes.
1037
+ * @param input The text to encode.
1038
+ */
195
1039
  encode(input?: string): Uint8Array;
1040
+ /**
1041
+ * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
1042
+ * containing the read Unicode code units and written UTF-8 bytes.
1043
+ *
1044
+ * ```js
1045
+ * const encoder = new TextEncoder();
1046
+ * const src = 'this is some data';
1047
+ * const dest = new Uint8Array(10);
1048
+ * const { read, written } = encoder.encodeInto(src, dest);
1049
+ * ```
1050
+ * @param src The text to encode.
1051
+ * @param dest The array to hold the encode result.
1052
+ */
196
1053
  encodeInto(input: string, output: Uint8Array): EncodeIntoResult;
197
1054
  }
198
1055
  }
199
-
200
1056
  declare module 'util/types' {
201
1057
  export * from 'util/types';
202
1058
  }
203
-
204
1059
  declare module 'util/types' {
205
1060
  import { KeyObject, webcrypto } from 'node:crypto';
206
-
1061
+ /**
1062
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
1063
+ * or[`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1064
+ *
1065
+ * See also `util.types.isArrayBuffer()` and `util.types.isSharedArrayBuffer()`.
1066
+ *
1067
+ * ```js
1068
+ * util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true
1069
+ * util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true
1070
+ * ```
1071
+ * @since v10.0.0
1072
+ */
207
1073
  function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
1074
+ /**
1075
+ * Returns `true` if the value is an `arguments` object.
1076
+ *
1077
+ * ```js
1078
+ * function foo() {
1079
+ * util.types.isArgumentsObject(arguments); // Returns true
1080
+ * }
1081
+ * ```
1082
+ * @since v10.0.0
1083
+ */
208
1084
  function isArgumentsObject(object: unknown): object is IArguments;
1085
+ /**
1086
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instance.
1087
+ * This does _not_ include [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances. Usually, it is
1088
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1089
+ *
1090
+ * ```js
1091
+ * util.types.isArrayBuffer(new ArrayBuffer()); // Returns true
1092
+ * util.types.isArrayBuffer(new SharedArrayBuffer()); // Returns false
1093
+ * ```
1094
+ * @since v10.0.0
1095
+ */
209
1096
  function isArrayBuffer(object: unknown): object is ArrayBuffer;
1097
+ /**
1098
+ * Returns `true` if the value is an instance of one of the [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)views, such as typed array
1099
+ * objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent
1100
+ * to[`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1101
+ *
1102
+ * ```js
1103
+ * util.types.isArrayBufferView(new Int8Array()); // true
1104
+ * util.types.isArrayBufferView(Buffer.from('hello world')); // true
1105
+ * util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true
1106
+ * util.types.isArrayBufferView(new ArrayBuffer()); // false
1107
+ * ```
1108
+ * @since v10.0.0
1109
+ */
210
1110
  function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
1111
+ /**
1112
+ * Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
1113
+ * This only reports back what the JavaScript engine is seeing;
1114
+ * in particular, the return value may not match the original source code if
1115
+ * a transpilation tool was used.
1116
+ *
1117
+ * ```js
1118
+ * util.types.isAsyncFunction(function foo() {}); // Returns false
1119
+ * util.types.isAsyncFunction(async function foo() {}); // Returns true
1120
+ * ```
1121
+ * @since v10.0.0
1122
+ */
211
1123
  function isAsyncFunction(object: unknown): boolean;
1124
+ /**
1125
+ * Returns `true` if the value is a `BigInt64Array` instance.
1126
+ *
1127
+ * ```js
1128
+ * util.types.isBigInt64Array(new BigInt64Array()); // Returns true
1129
+ * util.types.isBigInt64Array(new BigUint64Array()); // Returns false
1130
+ * ```
1131
+ * @since v10.0.0
1132
+ */
212
1133
  function isBigInt64Array(value: unknown): value is BigInt64Array;
1134
+ /**
1135
+ * Returns `true` if the value is a `BigUint64Array` instance.
1136
+ *
1137
+ * ```js
1138
+ * util.types.isBigUint64Array(new BigInt64Array()); // Returns false
1139
+ * util.types.isBigUint64Array(new BigUint64Array()); // Returns true
1140
+ * ```
1141
+ * @since v10.0.0
1142
+ */
213
1143
  function isBigUint64Array(value: unknown): value is BigUint64Array;
1144
+ /**
1145
+ * Returns `true` if the value is a boolean object, e.g. created
1146
+ * by `new Boolean()`.
1147
+ *
1148
+ * ```js
1149
+ * util.types.isBooleanObject(false); // Returns false
1150
+ * util.types.isBooleanObject(true); // Returns false
1151
+ * util.types.isBooleanObject(new Boolean(false)); // Returns true
1152
+ * util.types.isBooleanObject(new Boolean(true)); // Returns true
1153
+ * util.types.isBooleanObject(Boolean(false)); // Returns false
1154
+ * util.types.isBooleanObject(Boolean(true)); // Returns false
1155
+ * ```
1156
+ * @since v10.0.0
1157
+ */
214
1158
  function isBooleanObject(object: unknown): object is Boolean;
1159
+ /**
1160
+ * Returns `true` if the value is any boxed primitive object, e.g. created
1161
+ * by `new Boolean()`, `new String()` or `Object(Symbol())`.
1162
+ *
1163
+ * For example:
1164
+ *
1165
+ * ```js
1166
+ * util.types.isBoxedPrimitive(false); // Returns false
1167
+ * util.types.isBoxedPrimitive(new Boolean(false)); // Returns true
1168
+ * util.types.isBoxedPrimitive(Symbol('foo')); // Returns false
1169
+ * util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true
1170
+ * util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true
1171
+ * ```
1172
+ * @since v10.11.0
1173
+ */
215
1174
  function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
1175
+ /**
1176
+ * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
1177
+ *
1178
+ * ```js
1179
+ * const ab = new ArrayBuffer(20);
1180
+ * util.types.isDataView(new DataView(ab)); // Returns true
1181
+ * util.types.isDataView(new Float64Array()); // Returns false
1182
+ * ```
1183
+ *
1184
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1185
+ * @since v10.0.0
1186
+ */
216
1187
  function isDataView(object: unknown): object is DataView;
1188
+ /**
1189
+ * Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance.
1190
+ *
1191
+ * ```js
1192
+ * util.types.isDate(new Date()); // Returns true
1193
+ * ```
1194
+ * @since v10.0.0
1195
+ */
217
1196
  function isDate(object: unknown): object is Date;
1197
+ /**
1198
+ * Returns `true` if the value is a native `External` value.
1199
+ *
1200
+ * A native `External` value is a special type of object that contains a
1201
+ * raw C++ pointer (`void*`) for access from native code, and has no other
1202
+ * properties. Such objects are created either by Node.js internals or native
1203
+ * addons. In JavaScript, they are [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a`null` prototype.
1204
+ *
1205
+ * ```c
1206
+ * #include <js_native_api.h>
1207
+ * #include <stdlib.h>
1208
+ * napi_value result;
1209
+ * static napi_value MyNapi(napi_env env, napi_callback_info info) {
1210
+ * int* raw = (int*) malloc(1024);
1211
+ * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &#x26;result);
1212
+ * if (status != napi_ok) {
1213
+ * napi_throw_error(env, NULL, "napi_create_external failed");
1214
+ * return NULL;
1215
+ * }
1216
+ * return result;
1217
+ * }
1218
+ * ...
1219
+ * DECLARE_NAPI_PROPERTY("myNapi", MyNapi)
1220
+ * ...
1221
+ * ```
1222
+ *
1223
+ * ```js
1224
+ * const native = require('napi_addon.node');
1225
+ * const data = native.myNapi();
1226
+ * util.types.isExternal(data); // returns true
1227
+ * util.types.isExternal(0); // returns false
1228
+ * util.types.isExternal(new String('foo')); // returns false
1229
+ * ```
1230
+ *
1231
+ * For further information on `napi_create_external`, refer to `napi_create_external()`.
1232
+ * @since v10.0.0
1233
+ */
218
1234
  function isExternal(object: unknown): boolean;
1235
+ /**
1236
+ * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
1237
+ *
1238
+ * ```js
1239
+ * util.types.isFloat32Array(new ArrayBuffer()); // Returns false
1240
+ * util.types.isFloat32Array(new Float32Array()); // Returns true
1241
+ * util.types.isFloat32Array(new Float64Array()); // Returns false
1242
+ * ```
1243
+ * @since v10.0.0
1244
+ */
219
1245
  function isFloat32Array(object: unknown): object is Float32Array;
1246
+ /**
1247
+ * Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance.
1248
+ *
1249
+ * ```js
1250
+ * util.types.isFloat64Array(new ArrayBuffer()); // Returns false
1251
+ * util.types.isFloat64Array(new Uint8Array()); // Returns false
1252
+ * util.types.isFloat64Array(new Float64Array()); // Returns true
1253
+ * ```
1254
+ * @since v10.0.0
1255
+ */
220
1256
  function isFloat64Array(object: unknown): object is Float64Array;
1257
+ /**
1258
+ * Returns `true` if the value is a generator function.
1259
+ * This only reports back what the JavaScript engine is seeing;
1260
+ * in particular, the return value may not match the original source code if
1261
+ * a transpilation tool was used.
1262
+ *
1263
+ * ```js
1264
+ * util.types.isGeneratorFunction(function foo() {}); // Returns false
1265
+ * util.types.isGeneratorFunction(function* foo() {}); // Returns true
1266
+ * ```
1267
+ * @since v10.0.0
1268
+ */
221
1269
  function isGeneratorFunction(object: unknown): object is GeneratorFunction;
1270
+ /**
1271
+ * Returns `true` if the value is a generator object as returned from a
1272
+ * built-in generator function.
1273
+ * This only reports back what the JavaScript engine is seeing;
1274
+ * in particular, the return value may not match the original source code if
1275
+ * a transpilation tool was used.
1276
+ *
1277
+ * ```js
1278
+ * function* foo() {}
1279
+ * const generator = foo();
1280
+ * util.types.isGeneratorObject(generator); // Returns true
1281
+ * ```
1282
+ * @since v10.0.0
1283
+ */
222
1284
  function isGeneratorObject(object: unknown): object is Generator;
1285
+ /**
1286
+ * Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance.
1287
+ *
1288
+ * ```js
1289
+ * util.types.isInt8Array(new ArrayBuffer()); // Returns false
1290
+ * util.types.isInt8Array(new Int8Array()); // Returns true
1291
+ * util.types.isInt8Array(new Float64Array()); // Returns false
1292
+ * ```
1293
+ * @since v10.0.0
1294
+ */
223
1295
  function isInt8Array(object: unknown): object is Int8Array;
1296
+ /**
1297
+ * Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance.
1298
+ *
1299
+ * ```js
1300
+ * util.types.isInt16Array(new ArrayBuffer()); // Returns false
1301
+ * util.types.isInt16Array(new Int16Array()); // Returns true
1302
+ * util.types.isInt16Array(new Float64Array()); // Returns false
1303
+ * ```
1304
+ * @since v10.0.0
1305
+ */
224
1306
  function isInt16Array(object: unknown): object is Int16Array;
1307
+ /**
1308
+ * Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance.
1309
+ *
1310
+ * ```js
1311
+ * util.types.isInt32Array(new ArrayBuffer()); // Returns false
1312
+ * util.types.isInt32Array(new Int32Array()); // Returns true
1313
+ * util.types.isInt32Array(new Float64Array()); // Returns false
1314
+ * ```
1315
+ * @since v10.0.0
1316
+ */
225
1317
  function isInt32Array(object: unknown): object is Int32Array;
226
- function isMap<T>(
227
- object: T | {},
228
- ): object is T extends ReadonlyMap<any, any>
229
- ? unknown extends T
230
- ? never
231
- : ReadonlyMap<any, any>
232
- : Map<unknown, unknown>;
1318
+ /**
1319
+ * Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
1320
+ *
1321
+ * ```js
1322
+ * util.types.isMap(new Map()); // Returns true
1323
+ * ```
1324
+ * @since v10.0.0
1325
+ */
1326
+ function isMap<T>(object: T | {}): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>) : Map<unknown, unknown>;
1327
+ /**
1328
+ * Returns `true` if the value is an iterator returned for a built-in[`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
1329
+ *
1330
+ * ```js
1331
+ * const map = new Map();
1332
+ * util.types.isMapIterator(map.keys()); // Returns true
1333
+ * util.types.isMapIterator(map.values()); // Returns true
1334
+ * util.types.isMapIterator(map.entries()); // Returns true
1335
+ * util.types.isMapIterator(map[Symbol.iterator]()); // Returns true
1336
+ * ```
1337
+ * @since v10.0.0
1338
+ */
233
1339
  function isMapIterator(object: unknown): boolean;
1340
+ /**
1341
+ * Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects).
1342
+ *
1343
+ * ```js
1344
+ * import * as ns from './a.js';
1345
+ *
1346
+ * util.types.isModuleNamespaceObject(ns); // Returns true
1347
+ * ```
1348
+ * @since v10.0.0
1349
+ */
234
1350
  function isModuleNamespaceObject(value: unknown): boolean;
1351
+ /**
1352
+ * Returns `true` if the value is an instance of a built-in `Error` type.
1353
+ *
1354
+ * ```js
1355
+ * util.types.isNativeError(new Error()); // Returns true
1356
+ * util.types.isNativeError(new TypeError()); // Returns true
1357
+ * util.types.isNativeError(new RangeError()); // Returns true
1358
+ * ```
1359
+ * @since v10.0.0
1360
+ */
235
1361
  function isNativeError(object: unknown): object is Error;
1362
+ /**
1363
+ * Returns `true` if the value is a number object, e.g. created
1364
+ * by `new Number()`.
1365
+ *
1366
+ * ```js
1367
+ * util.types.isNumberObject(0); // Returns false
1368
+ * util.types.isNumberObject(new Number(0)); // Returns true
1369
+ * ```
1370
+ * @since v10.0.0
1371
+ */
236
1372
  function isNumberObject(object: unknown): object is Number;
1373
+ /**
1374
+ * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
1375
+ *
1376
+ * ```js
1377
+ * util.types.isPromise(Promise.resolve(42)); // Returns true
1378
+ * ```
1379
+ * @since v10.0.0
1380
+ */
237
1381
  function isPromise(object: unknown): object is Promise<unknown>;
1382
+ /**
1383
+ * Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance.
1384
+ *
1385
+ * ```js
1386
+ * const target = {};
1387
+ * const proxy = new Proxy(target, {});
1388
+ * util.types.isProxy(target); // Returns false
1389
+ * util.types.isProxy(proxy); // Returns true
1390
+ * ```
1391
+ * @since v10.0.0
1392
+ */
238
1393
  function isProxy(object: unknown): boolean;
1394
+ /**
1395
+ * Returns `true` if the value is a regular expression object.
1396
+ *
1397
+ * ```js
1398
+ * util.types.isRegExp(/abc/); // Returns true
1399
+ * util.types.isRegExp(new RegExp('abc')); // Returns true
1400
+ * ```
1401
+ * @since v10.0.0
1402
+ */
239
1403
  function isRegExp(object: unknown): object is RegExp;
240
- function isSet<T>(
241
- object: T | {},
242
- ): object is T extends ReadonlySet<any>
243
- ? unknown extends T
244
- ? never
245
- : ReadonlySet<any>
246
- : Set<unknown>;
1404
+ /**
1405
+ * Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
1406
+ *
1407
+ * ```js
1408
+ * util.types.isSet(new Set()); // Returns true
1409
+ * ```
1410
+ * @since v10.0.0
1411
+ */
1412
+ function isSet<T>(object: T | {}): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
1413
+ /**
1414
+ * Returns `true` if the value is an iterator returned for a built-in[`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
1415
+ *
1416
+ * ```js
1417
+ * const set = new Set();
1418
+ * util.types.isSetIterator(set.keys()); // Returns true
1419
+ * util.types.isSetIterator(set.values()); // Returns true
1420
+ * util.types.isSetIterator(set.entries()); // Returns true
1421
+ * util.types.isSetIterator(set[Symbol.iterator]()); // Returns true
1422
+ * ```
1423
+ * @since v10.0.0
1424
+ */
247
1425
  function isSetIterator(object: unknown): boolean;
1426
+ /**
1427
+ * Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1428
+ * This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is
1429
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1430
+ *
1431
+ * ```js
1432
+ * util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false
1433
+ * util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true
1434
+ * ```
1435
+ * @since v10.0.0
1436
+ */
248
1437
  function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
1438
+ /**
1439
+ * Returns `true` if the value is a string object, e.g. created
1440
+ * by `new String()`.
1441
+ *
1442
+ * ```js
1443
+ * util.types.isStringObject('foo'); // Returns false
1444
+ * util.types.isStringObject(new String('foo')); // Returns true
1445
+ * ```
1446
+ * @since v10.0.0
1447
+ */
249
1448
  function isStringObject(object: unknown): object is String;
1449
+ /**
1450
+ * Returns `true` if the value is a symbol object, created
1451
+ * by calling `Object()` on a `Symbol` primitive.
1452
+ *
1453
+ * ```js
1454
+ * const symbol = Symbol('foo');
1455
+ * util.types.isSymbolObject(symbol); // Returns false
1456
+ * util.types.isSymbolObject(Object(symbol)); // Returns true
1457
+ * ```
1458
+ * @since v10.0.0
1459
+ */
250
1460
  function isSymbolObject(object: unknown): object is Symbol;
1461
+ /**
1462
+ * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
1463
+ *
1464
+ * ```js
1465
+ * util.types.isTypedArray(new ArrayBuffer()); // Returns false
1466
+ * util.types.isTypedArray(new Uint8Array()); // Returns true
1467
+ * util.types.isTypedArray(new Float64Array()); // Returns true
1468
+ * ```
1469
+ *
1470
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1471
+ * @since v10.0.0
1472
+ */
251
1473
  function isTypedArray(object: unknown): object is NodeJS.TypedArray;
1474
+ /**
1475
+ * Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance.
1476
+ *
1477
+ * ```js
1478
+ * util.types.isUint8Array(new ArrayBuffer()); // Returns false
1479
+ * util.types.isUint8Array(new Uint8Array()); // Returns true
1480
+ * util.types.isUint8Array(new Float64Array()); // Returns false
1481
+ * ```
1482
+ * @since v10.0.0
1483
+ */
252
1484
  function isUint8Array(object: unknown): object is Uint8Array;
1485
+ /**
1486
+ * Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance.
1487
+ *
1488
+ * ```js
1489
+ * util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
1490
+ * util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true
1491
+ * util.types.isUint8ClampedArray(new Float64Array()); // Returns false
1492
+ * ```
1493
+ * @since v10.0.0
1494
+ */
253
1495
  function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
1496
+ /**
1497
+ * Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance.
1498
+ *
1499
+ * ```js
1500
+ * util.types.isUint16Array(new ArrayBuffer()); // Returns false
1501
+ * util.types.isUint16Array(new Uint16Array()); // Returns true
1502
+ * util.types.isUint16Array(new Float64Array()); // Returns false
1503
+ * ```
1504
+ * @since v10.0.0
1505
+ */
254
1506
  function isUint16Array(object: unknown): object is Uint16Array;
1507
+ /**
1508
+ * Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance.
1509
+ *
1510
+ * ```js
1511
+ * util.types.isUint32Array(new ArrayBuffer()); // Returns false
1512
+ * util.types.isUint32Array(new Uint32Array()); // Returns true
1513
+ * util.types.isUint32Array(new Float64Array()); // Returns false
1514
+ * ```
1515
+ * @since v10.0.0
1516
+ */
255
1517
  function isUint32Array(object: unknown): object is Uint32Array;
1518
+ /**
1519
+ * Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance.
1520
+ *
1521
+ * ```js
1522
+ * util.types.isWeakMap(new WeakMap()); // Returns true
1523
+ * ```
1524
+ * @since v10.0.0
1525
+ */
256
1526
  function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
1527
+ /**
1528
+ * Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance.
1529
+ *
1530
+ * ```js
1531
+ * util.types.isWeakSet(new WeakSet()); // Returns true
1532
+ * ```
1533
+ * @since v10.0.0
1534
+ */
257
1535
  function isWeakSet(object: unknown): object is WeakSet<object>;
1536
+ /**
1537
+ * Returns `true` if `value` is a `<KeyObject>`, `false` otherwise.
1538
+ * @since v16.2.0
1539
+ */
258
1540
  function isKeyObject(object: unknown): object is KeyObject;
1541
+ /**
1542
+ * Returns `true` if `value` is a `<CryptoKey>`, `false` otherwise.
1543
+ * @since v16.2.0
1544
+ */
259
1545
  function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
260
1546
  }
261
-
262
1547
  declare module 'node:util' {
263
1548
  export * from 'util';
264
1549
  }
265
-
266
1550
  declare module 'node:util/types' {
267
1551
  export * from 'util/types';
268
1552
  }