@node-red/editor-client 3.1.8 → 4.0.0-beta.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 (149) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/en-US/editor.json +10 -1
  3. package/locales/fr/editor.json +8 -1
  4. package/locales/ja/editor.json +10 -3
  5. package/package.json +1 -1
  6. package/public/red/about +52 -0
  7. package/public/red/red.js +1433 -263
  8. package/public/red/red.min.js +3 -3
  9. package/public/red/style.min.css +2 -2
  10. package/public/red/tours/3.1/welcome.js +231 -0
  11. package/public/red/tours/images/nr4-auto-complete.png +0 -0
  12. package/public/red/tours/images/nr4-config-select.png +0 -0
  13. package/public/red/tours/images/nr4-multiplayer.png +0 -0
  14. package/public/red/tours/images/nr4-plugins.png +0 -0
  15. package/public/red/tours/images/nr4-sf-config.png +0 -0
  16. package/public/red/tours/images/nr4-timestamp-formatting.png +0 -0
  17. package/public/red/tours/welcome.js +105 -161
  18. package/public/types/node/assert/strict.d.ts +1 -1
  19. package/public/types/node/assert.d.ts +8 -9
  20. package/public/types/node/async_hooks.d.ts +9 -5
  21. package/public/types/node/buffer.d.ts +43 -18
  22. package/public/types/node/child_process.d.ts +8 -5
  23. package/public/types/node/cluster.d.ts +15 -19
  24. package/public/types/node/console.d.ts +2 -2
  25. package/public/types/node/crypto.d.ts +165 -70
  26. package/public/types/node/dgram.d.ts +4 -4
  27. package/public/types/node/diagnostics_channel.d.ts +8 -7
  28. package/public/types/node/dns/promises.d.ts +11 -9
  29. package/public/types/node/dns.d.ts +18 -13
  30. package/public/types/node/dom-events.d.ts +129 -0
  31. package/public/types/node/domain.d.ts +2 -2
  32. package/public/types/node/events.d.ts +49 -12
  33. package/public/types/node/fs/promises.d.ts +68 -24
  34. package/public/types/node/fs.d.ts +132 -59
  35. package/public/types/node/globals.d.ts +31 -17
  36. package/public/types/node/http.d.ts +138 -27
  37. package/public/types/node/http2.d.ts +38 -5
  38. package/public/types/node/https.d.ts +12 -3
  39. package/public/types/node/module.d.ts +1 -2
  40. package/public/types/node/net.d.ts +69 -28
  41. package/public/types/node/os.d.ts +16 -5
  42. package/public/types/node/path.d.ts +5 -5
  43. package/public/types/node/perf_hooks.d.ts +48 -9
  44. package/public/types/node/process.d.ts +18 -17
  45. package/public/types/node/querystring.d.ts +2 -2
  46. package/public/types/node/readline/promises.d.ts +146 -0
  47. package/public/types/node/readline.d.ts +141 -31
  48. package/public/types/node/stream/consumers.d.ts +2 -2
  49. package/public/types/node/stream/promises.d.ts +1 -1
  50. package/public/types/node/stream/web.d.ts +4 -66
  51. package/public/types/node/stream.d.ts +96 -118
  52. package/public/types/node/string_decoder.d.ts +2 -2
  53. package/public/types/node/test.d.ts +200 -16
  54. package/public/types/node/timers/promises.d.ts +1 -26
  55. package/public/types/node/timers.d.ts +2 -2
  56. package/public/types/node/tls.d.ts +21 -12
  57. package/public/types/node/trace_events.d.ts +12 -2
  58. package/public/types/node/ts4.8/assert/strict.d.ts +11 -0
  59. package/public/types/node/ts4.8/assert.d.ts +964 -0
  60. package/public/types/node/ts4.8/async_hooks.d.ts +504 -0
  61. package/public/types/node/ts4.8/buffer.d.ts +2262 -0
  62. package/public/types/node/ts4.8/child_process.d.ts +1372 -0
  63. package/public/types/node/ts4.8/cluster.d.ts +413 -0
  64. package/public/types/node/ts4.8/console.d.ts +415 -0
  65. package/public/types/node/ts4.8/crypto.d.ts +3967 -0
  66. package/public/types/node/ts4.8/dgram.d.ts +548 -0
  67. package/public/types/node/ts4.8/diagnostics_channel.d.ts +156 -0
  68. package/public/types/node/ts4.8/dns/promises.d.ts +373 -0
  69. package/public/types/node/ts4.8/dns.d.ts +662 -0
  70. package/public/types/node/ts4.8/dom-events.d.ts +129 -0
  71. package/public/types/node/ts4.8/domain.d.ts +173 -0
  72. package/public/types/node/ts4.8/events.d.ts +681 -0
  73. package/public/types/node/ts4.8/fs/promises.d.ts +1141 -0
  74. package/public/types/node/ts4.8/fs.d.ts +3875 -0
  75. package/public/types/node/ts4.8/globals.d.ts +297 -0
  76. package/public/types/node/ts4.8/http.d.ts +1617 -0
  77. package/public/types/node/ts4.8/http2.d.ts +2137 -0
  78. package/public/types/node/ts4.8/https.d.ts +544 -0
  79. package/public/types/node/ts4.8/module.d.ts +117 -0
  80. package/public/types/node/ts4.8/net.d.ts +872 -0
  81. package/public/types/node/ts4.8/os.d.ts +469 -0
  82. package/public/types/node/ts4.8/path.d.ts +194 -0
  83. package/public/types/node/ts4.8/perf_hooks.d.ts +628 -0
  84. package/public/types/node/ts4.8/process.d.ts +1485 -0
  85. package/public/types/node/ts4.8/querystring.d.ts +134 -0
  86. package/public/types/node/ts4.8/readline/promises.d.ts +146 -0
  87. package/public/types/node/ts4.8/readline.d.ts +656 -0
  88. package/public/types/node/ts4.8/stream/consumers.d.ts +15 -0
  89. package/public/types/node/ts4.8/stream/promises.d.ts +45 -0
  90. package/public/types/node/ts4.8/stream/web.d.ts +333 -0
  91. package/public/types/node/ts4.8/stream.d.ts +1343 -0
  92. package/public/types/node/ts4.8/string_decoder.d.ts +70 -0
  93. package/public/types/node/ts4.8/test.d.ts +377 -0
  94. package/public/types/node/ts4.8/timers/promises.d.ts +71 -0
  95. package/public/types/node/ts4.8/timers.d.ts +97 -0
  96. package/public/types/node/ts4.8/tls.d.ts +1031 -0
  97. package/public/types/node/ts4.8/trace_events.d.ts +174 -0
  98. package/public/types/node/ts4.8/tty.d.ts +209 -0
  99. package/public/types/node/ts4.8/url.d.ts +900 -0
  100. package/public/types/node/ts4.8/util.d.ts +1853 -0
  101. package/public/types/node/ts4.8/v8.d.ts +399 -0
  102. package/public/types/node/ts4.8/vm.d.ts +512 -0
  103. package/public/types/node/ts4.8/wasi.d.ts +161 -0
  104. package/public/types/node/ts4.8/worker_threads.d.ts +692 -0
  105. package/public/types/node/ts4.8/zlib.d.ts +520 -0
  106. package/public/types/node/tty.d.ts +5 -3
  107. package/public/types/node/url.d.ts +81 -39
  108. package/public/types/node/util.d.ts +269 -13
  109. package/public/types/node/v8.d.ts +22 -4
  110. package/public/types/node/vm.d.ts +7 -5
  111. package/public/types/node/wasi.d.ts +2 -2
  112. package/public/types/node/worker_threads.d.ts +51 -11
  113. package/public/types/node/zlib.d.ts +2 -2
  114. package/public/types/node-red/func.d.ts +26 -17
  115. package/public/vendor/ace/worker-jsonata.js +1 -1
  116. package/public/vendor/monaco/dist/{fa2cc0ab9f0bec2b3365.ttf → 0c718f5b7d2bce997c5f.ttf} +0 -0
  117. package/public/vendor/monaco/dist/css.worker.js +1 -1
  118. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  119. package/public/vendor/monaco/dist/editor.js +1 -29
  120. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +2 -2
  121. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  122. package/public/vendor/monaco/dist/html.worker.js +1 -1
  123. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  124. package/public/vendor/monaco/dist/json.worker.js +1 -1
  125. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  126. package/public/vendor/monaco/dist/locale/cs.js +324 -106
  127. package/public/vendor/monaco/dist/locale/de.js +336 -118
  128. package/public/vendor/monaco/dist/locale/es.js +329 -111
  129. package/public/vendor/monaco/dist/locale/fr.js +334 -116
  130. package/public/vendor/monaco/dist/locale/it.js +327 -109
  131. package/public/vendor/monaco/dist/locale/ja.js +329 -111
  132. package/public/vendor/monaco/dist/locale/ko.js +330 -112
  133. package/public/vendor/monaco/dist/locale/pl.js +329 -111
  134. package/public/vendor/monaco/dist/locale/pt-br.js +329 -111
  135. package/public/vendor/monaco/dist/locale/qps-ploc.js +330 -112
  136. package/public/vendor/monaco/dist/locale/ru.js +331 -113
  137. package/public/vendor/monaco/dist/locale/tr.js +329 -111
  138. package/public/vendor/monaco/dist/locale/zh-hans.js +331 -113
  139. package/public/vendor/monaco/dist/locale/zh-hant.js +331 -113
  140. package/public/vendor/monaco/dist/ts.worker.js +2 -2
  141. package/public/vendor/vendor.js +1 -1
  142. package/public/vendor/monaco/dist/7064e66c3890a12c47b4.ttf +0 -0
  143. /package/public/red/tours/{images → 3.1/images}/context-menu.png +0 -0
  144. /package/public/red/tours/{images → 3.1/images}/global-env-vars.png +0 -0
  145. /package/public/red/tours/{images → 3.1/images}/hiding-flows.png +0 -0
  146. /package/public/red/tours/{images → 3.1/images}/locking-flows.png +0 -0
  147. /package/public/red/tours/{images → 3.1/images}/mermaid.png +0 -0
  148. /package/public/red/tours/{images → 3.1/images}/node-help.png +0 -0
  149. /package/public/red/tours/{images → 3.1/images}/tab-changes.png +0 -0
@@ -0,0 +1,1853 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/node-red/nr-monaco-build */
3
+
4
+ /**
5
+ * The `util` module supports the needs of Node.js internal APIs. Many of the
6
+ * utilities are useful for application and module developers as well. To access
7
+ * it:
8
+ *
9
+ * ```js
10
+ * const util = require('util');
11
+ * ```
12
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/util.js)
13
+ */
14
+ declare module 'util' {
15
+ import * as types from 'node:util/types';
16
+ export interface InspectOptions {
17
+ /**
18
+ * If set to `true`, getters are going to be
19
+ * inspected as well. If set to `'get'` only getters without setter are going
20
+ * to be inspected. If set to `'set'` only getters having a corresponding
21
+ * setter are going to be inspected. This might cause side effects depending on
22
+ * the getter function.
23
+ * @default `false`
24
+ */
25
+ getters?: 'get' | 'set' | boolean | undefined;
26
+ showHidden?: boolean | undefined;
27
+ /**
28
+ * @default 2
29
+ */
30
+ depth?: number | null | undefined;
31
+ colors?: boolean | undefined;
32
+ customInspect?: boolean | undefined;
33
+ showProxy?: boolean | undefined;
34
+ maxArrayLength?: number | null | undefined;
35
+ /**
36
+ * Specifies the maximum number of characters to
37
+ * include when formatting. Set to `null` or `Infinity` to show all elements.
38
+ * Set to `0` or negative to show no characters.
39
+ * @default 10000
40
+ */
41
+ maxStringLength?: number | null | undefined;
42
+ breakLength?: number | undefined;
43
+ /**
44
+ * Setting this to `false` causes each object key
45
+ * to be displayed on a new line. It will also add new lines to text that is
46
+ * longer than `breakLength`. If set to a number, the most `n` inner elements
47
+ * are united on a single line as long as all properties fit into
48
+ * `breakLength`. Short array elements are also grouped together. Note that no
49
+ * text will be reduced below 16 characters, no matter the `breakLength` size.
50
+ * For more information, see the example below.
51
+ * @default `true`
52
+ */
53
+ compact?: boolean | number | undefined;
54
+ sorted?: boolean | ((a: string, b: string) => number) | undefined;
55
+ }
56
+ export type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
57
+ export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
58
+ export interface InspectOptionsStylized extends InspectOptions {
59
+ stylize(text: string, styleType: Style): string;
60
+ }
61
+ /**
62
+ * The `util.format()` method returns a formatted string using the first argument
63
+ * as a `printf`\-like format string which can contain zero or more format
64
+ * specifiers. Each specifier is replaced with the converted value from the
65
+ * corresponding argument. Supported specifiers are:
66
+ *
67
+ * If a specifier does not have a corresponding argument, it is not replaced:
68
+ *
69
+ * ```js
70
+ * util.format('%s:%s', 'foo');
71
+ * // Returns: 'foo:%s'
72
+ * ```
73
+ *
74
+ * Values that are not part of the format string are formatted using`util.inspect()` if their type is not `string`.
75
+ *
76
+ * If there are more arguments passed to the `util.format()` method than the
77
+ * number of specifiers, the extra arguments are concatenated to the returned
78
+ * string, separated by spaces:
79
+ *
80
+ * ```js
81
+ * util.format('%s:%s', 'foo', 'bar', 'baz');
82
+ * // Returns: 'foo:bar baz'
83
+ * ```
84
+ *
85
+ * 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:
86
+ *
87
+ * ```js
88
+ * util.format(1, 2, 3);
89
+ * // Returns: '1 2 3'
90
+ * ```
91
+ *
92
+ * If only one argument is passed to `util.format()`, it is returned as it is
93
+ * without any formatting:
94
+ *
95
+ * ```js
96
+ * util.format('%% %s');
97
+ * // Returns: '%% %s'
98
+ * ```
99
+ *
100
+ * `util.format()` is a synchronous method that is intended as a debugging tool.
101
+ * Some input values can have a significant performance overhead that can block the
102
+ * event loop. Use this function with care and never in a hot code path.
103
+ * @since v0.5.3
104
+ * @param format A `printf`-like format string.
105
+ */
106
+ export function format(format?: any, ...param: any[]): string;
107
+ /**
108
+ * This function is identical to {@link format}, except in that it takes
109
+ * an `inspectOptions` argument which specifies options that are passed along to {@link inspect}.
110
+ *
111
+ * ```js
112
+ * util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 });
113
+ * // Returns 'See object { foo: 42 }', where `42` is colored as a number
114
+ * // when printed to a terminal.
115
+ * ```
116
+ * @since v10.0.0
117
+ */
118
+ export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
119
+ /**
120
+ * Returns the string name for a numeric error code that comes from a Node.js API.
121
+ * The mapping between error codes and error names is platform-dependent.
122
+ * See `Common System Errors` for the names of common errors.
123
+ *
124
+ * ```js
125
+ * fs.access('file/that/does/not/exist', (err) => {
126
+ * const name = util.getSystemErrorName(err.errno);
127
+ * console.error(name); // ENOENT
128
+ * });
129
+ * ```
130
+ * @since v9.7.0
131
+ */
132
+ export function getSystemErrorName(err: number): string;
133
+ /**
134
+ * Returns a Map of all system error codes available from the Node.js API.
135
+ * The mapping between error codes and error names is platform-dependent.
136
+ * See `Common System Errors` for the names of common errors.
137
+ *
138
+ * ```js
139
+ * fs.access('file/that/does/not/exist', (err) => {
140
+ * const errorMap = util.getSystemErrorMap();
141
+ * const name = errorMap.get(err.errno);
142
+ * console.error(name); // ENOENT
143
+ * });
144
+ * ```
145
+ * @since v16.0.0, v14.17.0
146
+ */
147
+ export function getSystemErrorMap(): Map<number, [string, string]>;
148
+ /**
149
+ * The `util.log()` method prints the given `string` to `stdout` with an included
150
+ * timestamp.
151
+ *
152
+ * ```js
153
+ * const util = require('util');
154
+ *
155
+ * util.log('Timestamped message.');
156
+ * ```
157
+ * @since v0.3.0
158
+ * @deprecated Since v6.0.0 - Use a third party module instead.
159
+ */
160
+ export function log(string: string): void;
161
+ /**
162
+ * Returns the `string` after replacing any surrogate code points
163
+ * (or equivalently, any unpaired surrogate code units) with the
164
+ * Unicode "replacement character" U+FFFD.
165
+ * @since v16.8.0, v14.18.0
166
+ */
167
+ export function toUSVString(string: string): string;
168
+ /**
169
+ * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
170
+ * as transferable and can be used with `structuredClone()` or `postMessage()`.
171
+ * @since v18.11.0
172
+ * @returns A transferable AbortController
173
+ */
174
+ export function transferableAbortController(): AbortController;
175
+ /**
176
+ * Marks the given {AbortSignal} as transferable so that it can be used with
177
+ * `structuredClone()` and `postMessage()`.
178
+ *
179
+ * ```js
180
+ * const signal = transferableAbortSignal(AbortSignal.timeout(100));
181
+ * const channel = new MessageChannel();
182
+ * channel.port2.postMessage(signal, [signal]);
183
+ * ```
184
+ * @since v18.11.0
185
+ * @param signal The AbortSignal
186
+ * @returns The same AbortSignal
187
+ */
188
+ export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
189
+ /**
190
+ * The `util.inspect()` method returns a string representation of `object` that is
191
+ * intended for debugging. The output of `util.inspect` may change at any time
192
+ * and should not be depended upon programmatically. Additional `options` may be
193
+ * passed that alter the result.`util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
194
+ * an identifiable tag for an inspected value.
195
+ *
196
+ * ```js
197
+ * class Foo {
198
+ * get [Symbol.toStringTag]() {
199
+ * return 'bar';
200
+ * }
201
+ * }
202
+ *
203
+ * class Bar {}
204
+ *
205
+ * const baz = Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } });
206
+ *
207
+ * util.inspect(new Foo()); // 'Foo [bar] {}'
208
+ * util.inspect(new Bar()); // 'Bar {}'
209
+ * util.inspect(baz); // '[foo] {}'
210
+ * ```
211
+ *
212
+ * Circular references point to their anchor by using a reference index:
213
+ *
214
+ * ```js
215
+ * const { inspect } = require('util');
216
+ *
217
+ * const obj = {};
218
+ * obj.a = [obj];
219
+ * obj.b = {};
220
+ * obj.b.inner = obj.b;
221
+ * obj.b.obj = obj;
222
+ *
223
+ * console.log(inspect(obj));
224
+ * // <ref *1> {
225
+ * // a: [ [Circular *1] ],
226
+ * // b: <ref *2> { inner: [Circular *2], obj: [Circular *1] }
227
+ * // }
228
+ * ```
229
+ *
230
+ * The following example inspects all properties of the `util` object:
231
+ *
232
+ * ```js
233
+ * const util = require('util');
234
+ *
235
+ * console.log(util.inspect(util, { showHidden: true, depth: null }));
236
+ * ```
237
+ *
238
+ * The following example highlights the effect of the `compact` option:
239
+ *
240
+ * ```js
241
+ * const util = require('util');
242
+ *
243
+ * const o = {
244
+ * a: [1, 2, [[
245
+ * 'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' +
246
+ * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
247
+ * 'test',
248
+ * 'foo']], 4],
249
+ * b: new Map([['za', 1], ['zb', 'test']])
250
+ * };
251
+ * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
252
+ *
253
+ * // { a:
254
+ * // [ 1,
255
+ * // 2,
256
+ * // [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line
257
+ * // 'test',
258
+ * // 'foo' ] ],
259
+ * // 4 ],
260
+ * // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
261
+ *
262
+ * // Setting `compact` to false or an integer creates more reader friendly output.
263
+ * console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
264
+ *
265
+ * // {
266
+ * // a: [
267
+ * // 1,
268
+ * // 2,
269
+ * // [
270
+ * // [
271
+ * // 'Lorem ipsum dolor sit amet,\n' +
272
+ * // 'consectetur adipiscing elit, sed do eiusmod \n' +
273
+ * // 'tempor incididunt ut labore et dolore magna aliqua.',
274
+ * // 'test',
275
+ * // 'foo'
276
+ * // ]
277
+ * // ],
278
+ * // 4
279
+ * // ],
280
+ * // b: Map(2) {
281
+ * // 'za' => 1,
282
+ * // 'zb' => 'test'
283
+ * // }
284
+ * // }
285
+ *
286
+ * // Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a
287
+ * // single line.
288
+ * ```
289
+ *
290
+ * The `showHidden` option allows [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and
291
+ * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be
292
+ * inspected. If there are more entries than `maxArrayLength`, there is no
293
+ * 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
294
+ * result in different output. Furthermore, entries
295
+ * with no remaining strong references may be garbage collected at any time.
296
+ *
297
+ * ```js
298
+ * const { inspect } = require('util');
299
+ *
300
+ * const obj = { a: 1 };
301
+ * const obj2 = { b: 2 };
302
+ * const weakSet = new WeakSet([obj, obj2]);
303
+ *
304
+ * console.log(inspect(weakSet, { showHidden: true }));
305
+ * // WeakSet { { a: 1 }, { b: 2 } }
306
+ * ```
307
+ *
308
+ * The `sorted` option ensures that an object's property insertion order does not
309
+ * impact the result of `util.inspect()`.
310
+ *
311
+ * ```js
312
+ * const { inspect } = require('util');
313
+ * const assert = require('assert');
314
+ *
315
+ * const o1 = {
316
+ * b: [2, 3, 1],
317
+ * a: '`a` comes before `b`',
318
+ * c: new Set([2, 3, 1])
319
+ * };
320
+ * console.log(inspect(o1, { sorted: true }));
321
+ * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } }
322
+ * console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) }));
323
+ * // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' }
324
+ *
325
+ * const o2 = {
326
+ * c: new Set([2, 1, 3]),
327
+ * a: '`a` comes before `b`',
328
+ * b: [2, 3, 1]
329
+ * };
330
+ * assert.strict.equal(
331
+ * inspect(o1, { sorted: true }),
332
+ * inspect(o2, { sorted: true })
333
+ * );
334
+ * ```
335
+ *
336
+ * The `numericSeparator` option adds an underscore every three digits to all
337
+ * numbers.
338
+ *
339
+ * ```js
340
+ * const { inspect } = require('util');
341
+ *
342
+ * const thousand = 1_000;
343
+ * const million = 1_000_000;
344
+ * const bigNumber = 123_456_789n;
345
+ * const bigDecimal = 1_234.123_45;
346
+ *
347
+ * console.log(thousand, million, bigNumber, bigDecimal);
348
+ * // 1_000 1_000_000 123_456_789n 1_234.123_45
349
+ * ```
350
+ *
351
+ * `util.inspect()` is a synchronous method intended for debugging. Its maximum
352
+ * output length is approximately 128 MB. Inputs that result in longer output will
353
+ * be truncated.
354
+ * @since v0.3.0
355
+ * @param object Any JavaScript primitive or `Object`.
356
+ * @return The representation of `object`.
357
+ */
358
+ export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
359
+ export function inspect(object: any, options?: InspectOptions): string;
360
+ export namespace inspect {
361
+ let colors: NodeJS.Dict<[number, number]>;
362
+ let styles: {
363
+ [K in Style]: string;
364
+ };
365
+ let defaultOptions: InspectOptions;
366
+ /**
367
+ * Allows changing inspect settings from the repl.
368
+ */
369
+ let replDefaults: InspectOptions;
370
+ /**
371
+ * That can be used to declare custom inspect functions.
372
+ */
373
+ const custom: unique symbol;
374
+ }
375
+ /**
376
+ * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
377
+ *
378
+ * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
379
+ *
380
+ * ```js
381
+ * const util = require('util');
382
+ *
383
+ * util.isArray([]);
384
+ * // Returns: true
385
+ * util.isArray(new Array());
386
+ * // Returns: true
387
+ * util.isArray({});
388
+ * // Returns: false
389
+ * ```
390
+ * @since v0.6.0
391
+ * @deprecated Since v4.0.0 - Use `isArray` instead.
392
+ */
393
+ export function isArray(object: unknown): object is unknown[];
394
+ /**
395
+ * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
396
+ *
397
+ * ```js
398
+ * const util = require('util');
399
+ *
400
+ * util.isRegExp(/some regexp/);
401
+ * // Returns: true
402
+ * util.isRegExp(new RegExp('another regexp'));
403
+ * // Returns: true
404
+ * util.isRegExp({});
405
+ * // Returns: false
406
+ * ```
407
+ * @since v0.6.0
408
+ * @deprecated Since v4.0.0 - Deprecated
409
+ */
410
+ export function isRegExp(object: unknown): object is RegExp;
411
+ /**
412
+ * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
413
+ *
414
+ * ```js
415
+ * const util = require('util');
416
+ *
417
+ * util.isDate(new Date());
418
+ * // Returns: true
419
+ * util.isDate(Date());
420
+ * // false (without 'new' returns a String)
421
+ * util.isDate({});
422
+ * // Returns: false
423
+ * ```
424
+ * @since v0.6.0
425
+ * @deprecated Since v4.0.0 - Use {@link types.isDate} instead.
426
+ */
427
+ export function isDate(object: unknown): object is Date;
428
+ /**
429
+ * Returns `true` if the given `object` is an `Error`. Otherwise, returns`false`.
430
+ *
431
+ * ```js
432
+ * const util = require('util');
433
+ *
434
+ * util.isError(new Error());
435
+ * // Returns: true
436
+ * util.isError(new TypeError());
437
+ * // Returns: true
438
+ * util.isError({ name: 'Error', message: 'an error occurred' });
439
+ * // Returns: false
440
+ * ```
441
+ *
442
+ * This method relies on `Object.prototype.toString()` behavior. It is
443
+ * possible to obtain an incorrect result when the `object` argument manipulates`@@toStringTag`.
444
+ *
445
+ * ```js
446
+ * const util = require('util');
447
+ * const obj = { name: 'Error', message: 'an error occurred' };
448
+ *
449
+ * util.isError(obj);
450
+ * // Returns: false
451
+ * obj[Symbol.toStringTag] = 'Error';
452
+ * util.isError(obj);
453
+ * // Returns: true
454
+ * ```
455
+ * @since v0.6.0
456
+ * @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead.
457
+ */
458
+ export function isError(object: unknown): object is Error;
459
+ /**
460
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and`extends` keywords to get language level inheritance support. Also note
461
+ * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
462
+ *
463
+ * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
464
+ * prototype of `constructor` will be set to a new object created from`superConstructor`.
465
+ *
466
+ * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
467
+ * As an additional convenience, `superConstructor` will be accessible
468
+ * through the `constructor.super_` property.
469
+ *
470
+ * ```js
471
+ * const util = require('util');
472
+ * const EventEmitter = require('events');
473
+ *
474
+ * function MyStream() {
475
+ * EventEmitter.call(this);
476
+ * }
477
+ *
478
+ * util.inherits(MyStream, EventEmitter);
479
+ *
480
+ * MyStream.prototype.write = function(data) {
481
+ * this.emit('data', data);
482
+ * };
483
+ *
484
+ * const stream = new MyStream();
485
+ *
486
+ * console.log(stream instanceof EventEmitter); // true
487
+ * console.log(MyStream.super_ === EventEmitter); // true
488
+ *
489
+ * stream.on('data', (data) => {
490
+ * console.log(`Received data: "${data}"`);
491
+ * });
492
+ * stream.write('It works!'); // Received data: "It works!"
493
+ * ```
494
+ *
495
+ * ES6 example using `class` and `extends`:
496
+ *
497
+ * ```js
498
+ * const EventEmitter = require('events');
499
+ *
500
+ * class MyStream extends EventEmitter {
501
+ * write(data) {
502
+ * this.emit('data', data);
503
+ * }
504
+ * }
505
+ *
506
+ * const stream = new MyStream();
507
+ *
508
+ * stream.on('data', (data) => {
509
+ * console.log(`Received data: "${data}"`);
510
+ * });
511
+ * stream.write('With ES6');
512
+ * ```
513
+ * @since v0.3.0
514
+ * @deprecated Legacy: Use ES2015 class syntax and `extends` keyword instead.
515
+ */
516
+ export function inherits(constructor: unknown, superConstructor: unknown): void;
517
+ export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
518
+ export interface DebugLogger extends DebugLoggerFunction {
519
+ enabled: boolean;
520
+ }
521
+ /**
522
+ * The `util.debuglog()` method is used to create a function that conditionally
523
+ * 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
524
+ * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
525
+ *
526
+ * ```js
527
+ * const util = require('util');
528
+ * const debuglog = util.debuglog('foo');
529
+ *
530
+ * debuglog('hello from foo [%d]', 123);
531
+ * ```
532
+ *
533
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then
534
+ * it will output something like:
535
+ *
536
+ * ```console
537
+ * FOO 3245: hello from foo [123]
538
+ * ```
539
+ *
540
+ * where `3245` is the process id. If it is not run with that
541
+ * environment variable set, then it will not print anything.
542
+ *
543
+ * The `section` supports wildcard also:
544
+ *
545
+ * ```js
546
+ * const util = require('util');
547
+ * const debuglog = util.debuglog('foo-bar');
548
+ *
549
+ * debuglog('hi there, it\'s foo-bar [%d]', 2333);
550
+ * ```
551
+ *
552
+ * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
553
+ * something like:
554
+ *
555
+ * ```console
556
+ * FOO-BAR 3257: hi there, it's foo-bar [2333]
557
+ * ```
558
+ *
559
+ * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`environment variable: `NODE_DEBUG=fs,net,tls`.
560
+ *
561
+ * The optional `callback` argument can be used to replace the logging function
562
+ * with a different function that doesn't have any initialization or
563
+ * unnecessary wrapping.
564
+ *
565
+ * ```js
566
+ * const util = require('util');
567
+ * let debuglog = util.debuglog('internals', (debug) => {
568
+ * // Replace with a logging function that optimizes out
569
+ * // testing if the section is enabled
570
+ * debuglog = debug;
571
+ * });
572
+ * ```
573
+ * @since v0.11.3
574
+ * @param section A string identifying the portion of the application for which the `debuglog` function is being created.
575
+ * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function.
576
+ * @return The logging function
577
+ */
578
+ export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
579
+ export const debug: typeof debuglog;
580
+ /**
581
+ * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
582
+ *
583
+ * ```js
584
+ * const util = require('util');
585
+ *
586
+ * util.isBoolean(1);
587
+ * // Returns: false
588
+ * util.isBoolean(0);
589
+ * // Returns: false
590
+ * util.isBoolean(false);
591
+ * // Returns: true
592
+ * ```
593
+ * @since v0.11.5
594
+ * @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead.
595
+ */
596
+ export function isBoolean(object: unknown): object is boolean;
597
+ /**
598
+ * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
599
+ *
600
+ * ```js
601
+ * const util = require('util');
602
+ *
603
+ * util.isBuffer({ length: 0 });
604
+ * // Returns: false
605
+ * util.isBuffer([]);
606
+ * // Returns: false
607
+ * util.isBuffer(Buffer.from('hello world'));
608
+ * // Returns: true
609
+ * ```
610
+ * @since v0.11.5
611
+ * @deprecated Since v4.0.0 - Use `isBuffer` instead.
612
+ */
613
+ export function isBuffer(object: unknown): object is Buffer;
614
+ /**
615
+ * Returns `true` if the given `object` is a `Function`. Otherwise, returns`false`.
616
+ *
617
+ * ```js
618
+ * const util = require('util');
619
+ *
620
+ * function Foo() {}
621
+ * const Bar = () => {};
622
+ *
623
+ * util.isFunction({});
624
+ * // Returns: false
625
+ * util.isFunction(Foo);
626
+ * // Returns: true
627
+ * util.isFunction(Bar);
628
+ * // Returns: true
629
+ * ```
630
+ * @since v0.11.5
631
+ * @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead.
632
+ */
633
+ export function isFunction(object: unknown): boolean;
634
+ /**
635
+ * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
636
+ *
637
+ * ```js
638
+ * const util = require('util');
639
+ *
640
+ * util.isNull(0);
641
+ * // Returns: false
642
+ * util.isNull(undefined);
643
+ * // Returns: false
644
+ * util.isNull(null);
645
+ * // Returns: true
646
+ * ```
647
+ * @since v0.11.5
648
+ * @deprecated Since v4.0.0 - Use `value === null` instead.
649
+ */
650
+ export function isNull(object: unknown): object is null;
651
+ /**
652
+ * Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
653
+ * returns `false`.
654
+ *
655
+ * ```js
656
+ * const util = require('util');
657
+ *
658
+ * util.isNullOrUndefined(0);
659
+ * // Returns: false
660
+ * util.isNullOrUndefined(undefined);
661
+ * // Returns: true
662
+ * util.isNullOrUndefined(null);
663
+ * // Returns: true
664
+ * ```
665
+ * @since v0.11.5
666
+ * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
667
+ */
668
+ export function isNullOrUndefined(object: unknown): object is null | undefined;
669
+ /**
670
+ * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
671
+ *
672
+ * ```js
673
+ * const util = require('util');
674
+ *
675
+ * util.isNumber(false);
676
+ * // Returns: false
677
+ * util.isNumber(Infinity);
678
+ * // Returns: true
679
+ * util.isNumber(0);
680
+ * // Returns: true
681
+ * util.isNumber(NaN);
682
+ * // Returns: true
683
+ * ```
684
+ * @since v0.11.5
685
+ * @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead.
686
+ */
687
+ export function isNumber(object: unknown): object is number;
688
+ /**
689
+ * Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript).
690
+ * Otherwise, returns `false`.
691
+ *
692
+ * ```js
693
+ * const util = require('util');
694
+ *
695
+ * util.isObject(5);
696
+ * // Returns: false
697
+ * util.isObject(null);
698
+ * // Returns: false
699
+ * util.isObject({});
700
+ * // Returns: true
701
+ * util.isObject(() => {});
702
+ * // Returns: false
703
+ * ```
704
+ * @since v0.11.5
705
+ * @deprecated Since v4.0.0 - Deprecated: Use `value !== null && typeof value === 'object'` instead.
706
+ */
707
+ export function isObject(object: unknown): boolean;
708
+ /**
709
+ * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
710
+ *
711
+ * ```js
712
+ * const util = require('util');
713
+ *
714
+ * util.isPrimitive(5);
715
+ * // Returns: true
716
+ * util.isPrimitive('foo');
717
+ * // Returns: true
718
+ * util.isPrimitive(false);
719
+ * // Returns: true
720
+ * util.isPrimitive(null);
721
+ * // Returns: true
722
+ * util.isPrimitive(undefined);
723
+ * // Returns: true
724
+ * util.isPrimitive({});
725
+ * // Returns: false
726
+ * util.isPrimitive(() => {});
727
+ * // Returns: false
728
+ * util.isPrimitive(/^$/);
729
+ * // Returns: false
730
+ * util.isPrimitive(new Date());
731
+ * // Returns: false
732
+ * ```
733
+ * @since v0.11.5
734
+ * @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead.
735
+ */
736
+ export function isPrimitive(object: unknown): boolean;
737
+ /**
738
+ * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
739
+ *
740
+ * ```js
741
+ * const util = require('util');
742
+ *
743
+ * util.isString('');
744
+ * // Returns: true
745
+ * util.isString('foo');
746
+ * // Returns: true
747
+ * util.isString(String('foo'));
748
+ * // Returns: true
749
+ * util.isString(5);
750
+ * // Returns: false
751
+ * ```
752
+ * @since v0.11.5
753
+ * @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead.
754
+ */
755
+ export function isString(object: unknown): object is string;
756
+ /**
757
+ * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
758
+ *
759
+ * ```js
760
+ * const util = require('util');
761
+ *
762
+ * util.isSymbol(5);
763
+ * // Returns: false
764
+ * util.isSymbol('foo');
765
+ * // Returns: false
766
+ * util.isSymbol(Symbol('foo'));
767
+ * // Returns: true
768
+ * ```
769
+ * @since v0.11.5
770
+ * @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead.
771
+ */
772
+ export function isSymbol(object: unknown): object is symbol;
773
+ /**
774
+ * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
775
+ *
776
+ * ```js
777
+ * const util = require('util');
778
+ *
779
+ * const foo = undefined;
780
+ * util.isUndefined(5);
781
+ * // Returns: false
782
+ * util.isUndefined(foo);
783
+ * // Returns: true
784
+ * util.isUndefined(null);
785
+ * // Returns: false
786
+ * ```
787
+ * @since v0.11.5
788
+ * @deprecated Since v4.0.0 - Use `value === undefined` instead.
789
+ */
790
+ export function isUndefined(object: unknown): object is undefined;
791
+ /**
792
+ * The `util.deprecate()` method wraps `fn` (which may be a function or class) in
793
+ * such a way that it is marked as deprecated.
794
+ *
795
+ * ```js
796
+ * const util = require('util');
797
+ *
798
+ * exports.obsoleteFunction = util.deprecate(() => {
799
+ * // Do something here.
800
+ * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
801
+ * ```
802
+ *
803
+ * When called, `util.deprecate()` will return a function that will emit a`DeprecationWarning` using the `'warning'` event. The warning will
804
+ * be emitted and printed to `stderr` the first time the returned function is
805
+ * called. After the warning is emitted, the wrapped function is called without
806
+ * emitting a warning.
807
+ *
808
+ * If the same optional `code` is supplied in multiple calls to `util.deprecate()`,
809
+ * the warning will be emitted only once for that `code`.
810
+ *
811
+ * ```js
812
+ * const util = require('util');
813
+ *
814
+ * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
815
+ * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
816
+ * fn1(); // Emits a deprecation warning with code DEP0001
817
+ * fn2(); // Does not emit a deprecation warning because it has the same code
818
+ * ```
819
+ *
820
+ * If either the `--no-deprecation` or `--no-warnings` command-line flags are
821
+ * used, or if the `process.noDeprecation` property is set to `true`_prior_ to
822
+ * the first deprecation warning, the `util.deprecate()` method does nothing.
823
+ *
824
+ * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
825
+ * or the `process.traceDeprecation` property is set to `true`, a warning and a
826
+ * stack trace are printed to `stderr` the first time the deprecated function is
827
+ * called.
828
+ *
829
+ * If the `--throw-deprecation` command-line flag is set, or the`process.throwDeprecation` property is set to `true`, then an exception will be
830
+ * thrown when the deprecated function is called.
831
+ *
832
+ * The `--throw-deprecation` command-line flag and `process.throwDeprecation`property take precedence over `--trace-deprecation` and`process.traceDeprecation`.
833
+ * @since v0.8.0
834
+ * @param fn The function that is being deprecated.
835
+ * @param msg A warning message to display when the deprecated function is invoked.
836
+ * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
837
+ * @return The deprecated function wrapped to emit a warning.
838
+ */
839
+ export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
840
+ /**
841
+ * Returns `true` if there is deep strict equality between `val1` and `val2`.
842
+ * Otherwise, returns `false`.
843
+ *
844
+ * See `assert.deepStrictEqual()` for more information about deep strict
845
+ * equality.
846
+ * @since v9.0.0
847
+ */
848
+ export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
849
+ /**
850
+ * Returns `str` with any ANSI escape codes removed.
851
+ *
852
+ * ```js
853
+ * console.log(util.stripVTControlCharacters('\u001B[4mvalue\u001B[0m'));
854
+ * // Prints "value"
855
+ * ```
856
+ * @since v16.11.0
857
+ */
858
+ export function stripVTControlCharacters(str: string): string;
859
+ /**
860
+ * Takes an `async` function (or a function that returns a `Promise`) and returns a
861
+ * function following the error-first callback style, i.e. taking
862
+ * an `(err, value) => ...` callback as the last argument. In the callback, the
863
+ * first argument will be the rejection reason (or `null` if the `Promise`resolved), and the second argument will be the resolved value.
864
+ *
865
+ * ```js
866
+ * const util = require('util');
867
+ *
868
+ * async function fn() {
869
+ * return 'hello world';
870
+ * }
871
+ * const callbackFunction = util.callbackify(fn);
872
+ *
873
+ * callbackFunction((err, ret) => {
874
+ * if (err) throw err;
875
+ * console.log(ret);
876
+ * });
877
+ * ```
878
+ *
879
+ * Will print:
880
+ *
881
+ * ```text
882
+ * hello world
883
+ * ```
884
+ *
885
+ * The callback is executed asynchronously, and will have a limited stack trace.
886
+ * If the callback throws, the process will emit an `'uncaughtException'` event, and if not handled will exit.
887
+ *
888
+ * Since `null` has a special meaning as the first argument to a callback, if a
889
+ * wrapped function rejects a `Promise` with a falsy value as a reason, the value
890
+ * is wrapped in an `Error` with the original value stored in a field named`reason`.
891
+ *
892
+ * ```js
893
+ * function fn() {
894
+ * return Promise.reject(null);
895
+ * }
896
+ * const callbackFunction = util.callbackify(fn);
897
+ *
898
+ * callbackFunction((err, ret) => {
899
+ * // When the Promise was rejected with `null` it is wrapped with an Error and
900
+ * // the original value is stored in `reason`.
901
+ * err &#x26;&#x26; Object.hasOwn(err, 'reason') &#x26;&#x26; err.reason === null; // true
902
+ * });
903
+ * ```
904
+ * @since v8.2.0
905
+ * @param original An `async` function
906
+ * @return a callback style function
907
+ */
908
+ export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
909
+ export function callbackify<TResult>(fn: () => Promise<TResult>): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
910
+ export function callbackify<T1>(fn: (arg1: T1) => Promise<void>): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
911
+ export function callbackify<T1, TResult>(fn: (arg1: T1) => Promise<TResult>): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
912
+ export function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
913
+ 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;
914
+ 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;
915
+ export function callbackify<T1, T2, T3, TResult>(
916
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>
917
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
918
+ export function callbackify<T1, T2, T3, T4>(
919
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>
920
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
921
+ export function callbackify<T1, T2, T3, T4, TResult>(
922
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>
923
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
924
+ export function callbackify<T1, T2, T3, T4, T5>(
925
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>
926
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
927
+ export function callbackify<T1, T2, T3, T4, T5, TResult>(
928
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>
929
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
930
+ export function callbackify<T1, T2, T3, T4, T5, T6>(
931
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>
932
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
933
+ export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
934
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>
935
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
936
+ export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
937
+ __promisify__: TCustom;
938
+ }
939
+ export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
940
+ [promisify.custom]: TCustom;
941
+ }
942
+ export type CustomPromisify<TCustom extends Function> = CustomPromisifySymbol<TCustom> | CustomPromisifyLegacy<TCustom>;
943
+ /**
944
+ * Takes a function following the common error-first callback style, i.e. taking
945
+ * an `(err, value) => ...` callback as the last argument, and returns a version
946
+ * that returns promises.
947
+ *
948
+ * ```js
949
+ * const util = require('util');
950
+ * const fs = require('fs');
951
+ *
952
+ * const stat = util.promisify(fs.stat);
953
+ * stat('.').then((stats) => {
954
+ * // Do something with `stats`
955
+ * }).catch((error) => {
956
+ * // Handle the error.
957
+ * });
958
+ * ```
959
+ *
960
+ * Or, equivalently using `async function`s:
961
+ *
962
+ * ```js
963
+ * const util = require('util');
964
+ * const fs = require('fs');
965
+ *
966
+ * const stat = util.promisify(fs.stat);
967
+ *
968
+ * async function callStat() {
969
+ * const stats = await stat('.');
970
+ * console.log(`This directory is owned by ${stats.uid}`);
971
+ * }
972
+ * ```
973
+ *
974
+ * If there is an `original[util.promisify.custom]` property present, `promisify`will return its value, see `Custom promisified functions`.
975
+ *
976
+ * `promisify()` assumes that `original` is a function taking a callback as its
977
+ * 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
978
+ * an error-first callback, it will still be passed an error-first
979
+ * callback as its last argument.
980
+ *
981
+ * Using `promisify()` on class methods or other methods that use `this` may not
982
+ * work as expected unless handled specially:
983
+ *
984
+ * ```js
985
+ * const util = require('util');
986
+ *
987
+ * class Foo {
988
+ * constructor() {
989
+ * this.a = 42;
990
+ * }
991
+ *
992
+ * bar(callback) {
993
+ * callback(null, this.a);
994
+ * }
995
+ * }
996
+ *
997
+ * const foo = new Foo();
998
+ *
999
+ * const naiveBar = util.promisify(foo.bar);
1000
+ * // TypeError: Cannot read property 'a' of undefined
1001
+ * // naiveBar().then(a => console.log(a));
1002
+ *
1003
+ * naiveBar.call(foo).then((a) => console.log(a)); // '42'
1004
+ *
1005
+ * const bindBar = naiveBar.bind(foo);
1006
+ * bindBar().then((a) => console.log(a)); // '42'
1007
+ * ```
1008
+ * @since v8.0.0
1009
+ */
1010
+ export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
1011
+ export function promisify<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise<TResult>;
1012
+ export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
1013
+ export function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
1014
+ export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
1015
+ export function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
1016
+ export function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
1017
+ 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>;
1018
+ 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>;
1019
+ export function promisify<T1, T2, T3, T4, TResult>(
1020
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void
1021
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
1022
+ 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>;
1023
+ export function promisify<T1, T2, T3, T4, T5, TResult>(
1024
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void
1025
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
1026
+ export function promisify<T1, T2, T3, T4, T5>(
1027
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void
1028
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
1029
+ export function promisify(fn: Function): Function;
1030
+ export namespace promisify {
1031
+ /**
1032
+ * That can be used to declare custom promisified variants of functions.
1033
+ */
1034
+ const custom: unique symbol;
1035
+ }
1036
+ /**
1037
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
1038
+ *
1039
+ * ```js
1040
+ * const decoder = new TextDecoder();
1041
+ * const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
1042
+ * console.log(decoder.decode(u8arr)); // Hello
1043
+ * ```
1044
+ * @since v8.3.0
1045
+ */
1046
+ export class TextDecoder {
1047
+ /**
1048
+ * The encoding supported by the `TextDecoder` instance.
1049
+ */
1050
+ readonly encoding: string;
1051
+ /**
1052
+ * The value will be `true` if decoding errors result in a `TypeError` being
1053
+ * thrown.
1054
+ */
1055
+ readonly fatal: boolean;
1056
+ /**
1057
+ * The value will be `true` if the decoding result will include the byte order
1058
+ * mark.
1059
+ */
1060
+ readonly ignoreBOM: boolean;
1061
+ constructor(
1062
+ encoding?: string,
1063
+ options?: {
1064
+ fatal?: boolean | undefined;
1065
+ ignoreBOM?: boolean | undefined;
1066
+ }
1067
+ );
1068
+ /**
1069
+ * Decodes the `input` and returns a string. If `options.stream` is `true`, any
1070
+ * incomplete byte sequences occurring at the end of the `input` are buffered
1071
+ * internally and emitted after the next call to `textDecoder.decode()`.
1072
+ *
1073
+ * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a`TypeError` being thrown.
1074
+ * @param input An `ArrayBuffer`, `DataView` or `TypedArray` instance containing the encoded data.
1075
+ */
1076
+ decode(
1077
+ input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
1078
+ options?: {
1079
+ stream?: boolean | undefined;
1080
+ }
1081
+ ): string;
1082
+ }
1083
+ export interface EncodeIntoResult {
1084
+ /**
1085
+ * The read Unicode code units of input.
1086
+ */
1087
+ read: number;
1088
+ /**
1089
+ * The written UTF-8 bytes of output.
1090
+ */
1091
+ written: number;
1092
+ }
1093
+ export { types };
1094
+
1095
+ //// TextEncoder/Decoder
1096
+ /**
1097
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
1098
+ * instances of `TextEncoder` only support UTF-8 encoding.
1099
+ *
1100
+ * ```js
1101
+ * const encoder = new TextEncoder();
1102
+ * const uint8array = encoder.encode('this is some data');
1103
+ * ```
1104
+ *
1105
+ * The `TextEncoder` class is also available on the global object.
1106
+ * @since v8.3.0
1107
+ */
1108
+ export class TextEncoder {
1109
+ /**
1110
+ * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
1111
+ */
1112
+ readonly encoding: string;
1113
+ /**
1114
+ * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
1115
+ * encoded bytes.
1116
+ * @param [input='an empty string'] The text to encode.
1117
+ */
1118
+ encode(input?: string): Uint8Array;
1119
+ /**
1120
+ * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
1121
+ * containing the read Unicode code units and written UTF-8 bytes.
1122
+ *
1123
+ * ```js
1124
+ * const encoder = new TextEncoder();
1125
+ * const src = 'this is some data';
1126
+ * const dest = new Uint8Array(10);
1127
+ * const { read, written } = encoder.encodeInto(src, dest);
1128
+ * ```
1129
+ * @param src The text to encode.
1130
+ * @param dest The array to hold the encode result.
1131
+ */
1132
+ encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
1133
+ }
1134
+
1135
+ import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'util';
1136
+ global {
1137
+ /**
1138
+ * `TextDecoder` class is a global reference for `require('util').TextDecoder`
1139
+ * https://nodejs.org/api/globals.html#textdecoder
1140
+ * @since v11.0.0
1141
+ */
1142
+ var TextDecoder: typeof globalThis extends {
1143
+ onmessage: any;
1144
+ TextDecoder: infer TextDecoder;
1145
+ }
1146
+ ? TextDecoder
1147
+ : typeof _TextDecoder;
1148
+
1149
+ /**
1150
+ * `TextEncoder` class is a global reference for `require('util').TextEncoder`
1151
+ * https://nodejs.org/api/globals.html#textencoder
1152
+ * @since v11.0.0
1153
+ */
1154
+ var TextEncoder: typeof globalThis extends {
1155
+ onmessage: any;
1156
+ TextEncoder: infer TextEncoder;
1157
+ }
1158
+ ? TextEncoder
1159
+ : typeof _TextEncoder;
1160
+ }
1161
+
1162
+ //// parseArgs
1163
+ /**
1164
+ * Provides a high-level API for command-line argument parsing. Takes a
1165
+ * specification for the expected arguments and returns a structured object
1166
+ * with the parsed values and positionals.
1167
+ *
1168
+ * `config` provides arguments for parsing and configures the parser. It
1169
+ * supports the following properties:
1170
+ *
1171
+ * - `args` The array of argument strings. **Default:** `process.argv` with
1172
+ * `execPath` and `filename` removed.
1173
+ * - `options` Arguments known to the parser. Keys of `options` are the long
1174
+ * names of options and values are objects accepting the following properties:
1175
+ *
1176
+ * - `type` Type of argument, which must be either `boolean` (for options
1177
+ * which do not take values) or `string` (for options which do).
1178
+ * - `multiple` Whether this option can be provided multiple
1179
+ * times. If `true`, all values will be collected in an array. If
1180
+ * `false`, values for the option are last-wins. **Default:** `false`.
1181
+ * - `short` A single character alias for the option.
1182
+ * - `default` The default option value when it is not set by args. It
1183
+ * must be of the same type as the `type` property. When `multiple`
1184
+ * is `true`, it must be an array.
1185
+ *
1186
+ * - `strict`: Whether an error should be thrown when unknown arguments
1187
+ * are encountered, or when arguments are passed that do not match the
1188
+ * `type` configured in `options`. **Default:** `true`.
1189
+ * - `allowPositionals`: Whether this command accepts positional arguments.
1190
+ * **Default:** `false` if `strict` is `true`, otherwise `true`.
1191
+ * - `tokens`: Whether tokens {boolean} Return the parsed tokens. This is useful
1192
+ * for extending the built-in behavior, from adding additional checks through
1193
+ * to reprocessing the tokens in different ways.
1194
+ * **Default:** `false`.
1195
+ *
1196
+ * @returns The parsed command line arguments:
1197
+ *
1198
+ * - `values` A mapping of parsed option names with their string
1199
+ * or boolean values.
1200
+ * - `positionals` Positional arguments.
1201
+ * - `tokens` Detailed parse information (only if `tokens` was specified).
1202
+ *
1203
+ */
1204
+ export function parseArgs<T extends ParseArgsConfig>(config: T): ParsedResults<T>;
1205
+
1206
+ interface ParseArgsOptionConfig {
1207
+ type: 'string' | 'boolean';
1208
+ short?: string;
1209
+ multiple?: boolean;
1210
+ /**
1211
+ * @since v18.11.0
1212
+ */
1213
+ default?: string | boolean | string[] | boolean[];
1214
+ }
1215
+
1216
+ interface ParseArgsOptionsConfig {
1217
+ [longOption: string]: ParseArgsOptionConfig;
1218
+ }
1219
+
1220
+ export interface ParseArgsConfig {
1221
+ strict?: boolean;
1222
+ allowPositionals?: boolean;
1223
+ tokens?: boolean;
1224
+ options?: ParseArgsOptionsConfig;
1225
+ args?: string[];
1226
+ }
1227
+
1228
+ /*
1229
+ IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties.
1230
+ TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936
1231
+ This means it is impossible to distinguish between "field X is definitely not present" and "field X may or may not be present".
1232
+ But we expect users to generally provide their config inline or `as const`, which means TS will always know whether a given field is present.
1233
+ So this helper treats "not definitely present" (i.e., not `extends boolean`) as being "definitely not present", i.e. it should have its default value.
1234
+ This is technically incorrect but is a much nicer UX for the common case.
1235
+ The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false.
1236
+ */
1237
+ type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true
1238
+ ? IfTrue
1239
+ : T extends false
1240
+ ? IfFalse
1241
+ : IfTrue;
1242
+
1243
+ // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
1244
+ type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false
1245
+ ? IfFalse
1246
+ : T extends true
1247
+ ? IfTrue
1248
+ : IfFalse;
1249
+
1250
+ type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionConfig> = IfDefaultsTrue<
1251
+ T['strict'],
1252
+ O['type'] extends 'string' ? string : O['type'] extends 'boolean' ? boolean : string | boolean,
1253
+ string | boolean
1254
+ >;
1255
+
1256
+ type ParsedValues<T extends ParseArgsConfig> =
1257
+ & IfDefaultsTrue<T['strict'], unknown, { [longOption: string]: undefined | string | boolean }>
1258
+ & (T['options'] extends ParseArgsOptionsConfig
1259
+ ? {
1260
+ -readonly [LongOption in keyof T['options']]: IfDefaultsFalse<
1261
+ T['options'][LongOption]['multiple'],
1262
+ undefined | Array<ExtractOptionValue<T, T['options'][LongOption]>>,
1263
+ undefined | ExtractOptionValue<T, T['options'][LongOption]>
1264
+ >;
1265
+ }
1266
+ : {});
1267
+
1268
+ type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
1269
+ T['strict'],
1270
+ IfDefaultsFalse<T['allowPositionals'], string[], []>,
1271
+ IfDefaultsTrue<T['allowPositionals'], string[], []>
1272
+ >;
1273
+
1274
+ type PreciseTokenForOptions<
1275
+ K extends string,
1276
+ O extends ParseArgsOptionConfig,
1277
+ > = O['type'] extends 'string'
1278
+ ? {
1279
+ kind: 'option';
1280
+ index: number;
1281
+ name: K;
1282
+ rawName: string;
1283
+ value: string;
1284
+ inlineValue: boolean;
1285
+ }
1286
+ : O['type'] extends 'boolean'
1287
+ ? {
1288
+ kind: 'option';
1289
+ index: number;
1290
+ name: K;
1291
+ rawName: string;
1292
+ value: undefined;
1293
+ inlineValue: undefined;
1294
+ }
1295
+ : OptionToken & { name: K };
1296
+
1297
+ type TokenForOptions<
1298
+ T extends ParseArgsConfig,
1299
+ K extends keyof T['options'] = keyof T['options'],
1300
+ > = K extends unknown
1301
+ ? T['options'] extends ParseArgsOptionsConfig
1302
+ ? PreciseTokenForOptions<K & string, T['options'][K]>
1303
+ : OptionToken
1304
+ : never;
1305
+
1306
+ type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T['strict'], TokenForOptions<T>, OptionToken>;
1307
+
1308
+ type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1309
+ T['strict'],
1310
+ IfDefaultsFalse<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>,
1311
+ IfDefaultsTrue<T['allowPositionals'], { kind: 'positional'; index: number; value: string }, never>
1312
+ >;
1313
+
1314
+ type ParsedTokens<T extends ParseArgsConfig> = Array<
1315
+ ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: 'option-terminator'; index: number }
1316
+ >;
1317
+
1318
+ type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1319
+ T['tokens'],
1320
+ {
1321
+ values: ParsedValues<T>;
1322
+ positionals: ParsedPositionals<T>;
1323
+ tokens: ParsedTokens<T>;
1324
+ },
1325
+ {
1326
+ values: ParsedValues<T>;
1327
+ positionals: ParsedPositionals<T>;
1328
+ }
1329
+ >;
1330
+
1331
+ type OptionToken =
1332
+ | { kind: 'option'; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1333
+ | {
1334
+ kind: 'option';
1335
+ index: number;
1336
+ name: string;
1337
+ rawName: string;
1338
+ value: undefined;
1339
+ inlineValue: undefined;
1340
+ };
1341
+
1342
+ type Token =
1343
+ | OptionToken
1344
+ | { kind: 'positional'; index: number; value: string }
1345
+ | { kind: 'option-terminator'; index: number };
1346
+
1347
+ // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
1348
+ // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
1349
+ type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T
1350
+ ? {
1351
+ values: { [longOption: string]: undefined | string | boolean | Array<string | boolean> };
1352
+ positionals: string[];
1353
+ tokens?: Token[];
1354
+ }
1355
+ : PreciseParsedResults<T>;
1356
+ }
1357
+ declare module 'util/types' {
1358
+ export * from 'util/types';
1359
+ }
1360
+ declare module 'util/types' {
1361
+ import { KeyObject, webcrypto } from 'node:crypto';
1362
+ /**
1363
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or
1364
+ * [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1365
+ *
1366
+ * See also `util.types.isArrayBuffer()` and `util.types.isSharedArrayBuffer()`.
1367
+ *
1368
+ * ```js
1369
+ * util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true
1370
+ * util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true
1371
+ * ```
1372
+ * @since v10.0.0
1373
+ */
1374
+ function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
1375
+ /**
1376
+ * Returns `true` if the value is an `arguments` object.
1377
+ *
1378
+ * ```js
1379
+ * function foo() {
1380
+ * util.types.isArgumentsObject(arguments); // Returns true
1381
+ * }
1382
+ * ```
1383
+ * @since v10.0.0
1384
+ */
1385
+ function isArgumentsObject(object: unknown): object is IArguments;
1386
+ /**
1387
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instance.
1388
+ * This does _not_ include [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances. Usually, it is
1389
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1390
+ *
1391
+ * ```js
1392
+ * util.types.isArrayBuffer(new ArrayBuffer()); // Returns true
1393
+ * util.types.isArrayBuffer(new SharedArrayBuffer()); // Returns false
1394
+ * ```
1395
+ * @since v10.0.0
1396
+ */
1397
+ function isArrayBuffer(object: unknown): object is ArrayBuffer;
1398
+ /**
1399
+ * 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
1400
+ * array objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent to
1401
+ * [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1402
+ *
1403
+ * ```js
1404
+ * util.types.isArrayBufferView(new Int8Array()); // true
1405
+ * util.types.isArrayBufferView(Buffer.from('hello world')); // true
1406
+ * util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true
1407
+ * util.types.isArrayBufferView(new ArrayBuffer()); // false
1408
+ * ```
1409
+ * @since v10.0.0
1410
+ */
1411
+ function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
1412
+ /**
1413
+ * Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
1414
+ * This only reports back what the JavaScript engine is seeing;
1415
+ * in particular, the return value may not match the original source code if
1416
+ * a transpilation tool was used.
1417
+ *
1418
+ * ```js
1419
+ * util.types.isAsyncFunction(function foo() {}); // Returns false
1420
+ * util.types.isAsyncFunction(async function foo() {}); // Returns true
1421
+ * ```
1422
+ * @since v10.0.0
1423
+ */
1424
+ function isAsyncFunction(object: unknown): boolean;
1425
+ /**
1426
+ * Returns `true` if the value is a `BigInt64Array` instance.
1427
+ *
1428
+ * ```js
1429
+ * util.types.isBigInt64Array(new BigInt64Array()); // Returns true
1430
+ * util.types.isBigInt64Array(new BigUint64Array()); // Returns false
1431
+ * ```
1432
+ * @since v10.0.0
1433
+ */
1434
+ function isBigInt64Array(value: unknown): value is BigInt64Array;
1435
+ /**
1436
+ * Returns `true` if the value is a `BigUint64Array` instance.
1437
+ *
1438
+ * ```js
1439
+ * util.types.isBigUint64Array(new BigInt64Array()); // Returns false
1440
+ * util.types.isBigUint64Array(new BigUint64Array()); // Returns true
1441
+ * ```
1442
+ * @since v10.0.0
1443
+ */
1444
+ function isBigUint64Array(value: unknown): value is BigUint64Array;
1445
+ /**
1446
+ * Returns `true` if the value is a boolean object, e.g. created
1447
+ * by `new Boolean()`.
1448
+ *
1449
+ * ```js
1450
+ * util.types.isBooleanObject(false); // Returns false
1451
+ * util.types.isBooleanObject(true); // Returns false
1452
+ * util.types.isBooleanObject(new Boolean(false)); // Returns true
1453
+ * util.types.isBooleanObject(new Boolean(true)); // Returns true
1454
+ * util.types.isBooleanObject(Boolean(false)); // Returns false
1455
+ * util.types.isBooleanObject(Boolean(true)); // Returns false
1456
+ * ```
1457
+ * @since v10.0.0
1458
+ */
1459
+ function isBooleanObject(object: unknown): object is Boolean;
1460
+ /**
1461
+ * Returns `true` if the value is any boxed primitive object, e.g. created
1462
+ * by `new Boolean()`, `new String()` or `Object(Symbol())`.
1463
+ *
1464
+ * For example:
1465
+ *
1466
+ * ```js
1467
+ * util.types.isBoxedPrimitive(false); // Returns false
1468
+ * util.types.isBoxedPrimitive(new Boolean(false)); // Returns true
1469
+ * util.types.isBoxedPrimitive(Symbol('foo')); // Returns false
1470
+ * util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true
1471
+ * util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true
1472
+ * ```
1473
+ * @since v10.11.0
1474
+ */
1475
+ function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
1476
+ /**
1477
+ * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
1478
+ *
1479
+ * ```js
1480
+ * const ab = new ArrayBuffer(20);
1481
+ * util.types.isDataView(new DataView(ab)); // Returns true
1482
+ * util.types.isDataView(new Float64Array()); // Returns false
1483
+ * ```
1484
+ *
1485
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1486
+ * @since v10.0.0
1487
+ */
1488
+ function isDataView(object: unknown): object is DataView;
1489
+ /**
1490
+ * Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance.
1491
+ *
1492
+ * ```js
1493
+ * util.types.isDate(new Date()); // Returns true
1494
+ * ```
1495
+ * @since v10.0.0
1496
+ */
1497
+ function isDate(object: unknown): object is Date;
1498
+ /**
1499
+ * Returns `true` if the value is a native `External` value.
1500
+ *
1501
+ * A native `External` value is a special type of object that contains a
1502
+ * raw C++ pointer (`void*`) for access from native code, and has no other
1503
+ * properties. Such objects are created either by Node.js internals or native
1504
+ * 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.
1505
+ *
1506
+ * ```c
1507
+ * #include <js_native_api.h>
1508
+ * #include <stdlib.h>
1509
+ * napi_value result;
1510
+ * static napi_value MyNapi(napi_env env, napi_callback_info info) {
1511
+ * int* raw = (int*) malloc(1024);
1512
+ * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &#x26;result);
1513
+ * if (status != napi_ok) {
1514
+ * napi_throw_error(env, NULL, "napi_create_external failed");
1515
+ * return NULL;
1516
+ * }
1517
+ * return result;
1518
+ * }
1519
+ * ...
1520
+ * DECLARE_NAPI_PROPERTY("myNapi", MyNapi)
1521
+ * ...
1522
+ * ```
1523
+ *
1524
+ * ```js
1525
+ * const native = require('napi_addon.node');
1526
+ * const data = native.myNapi();
1527
+ * util.types.isExternal(data); // returns true
1528
+ * util.types.isExternal(0); // returns false
1529
+ * util.types.isExternal(new String('foo')); // returns false
1530
+ * ```
1531
+ *
1532
+ * For further information on `napi_create_external`, refer to `napi_create_external()`.
1533
+ * @since v10.0.0
1534
+ */
1535
+ function isExternal(object: unknown): boolean;
1536
+ /**
1537
+ * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
1538
+ *
1539
+ * ```js
1540
+ * util.types.isFloat32Array(new ArrayBuffer()); // Returns false
1541
+ * util.types.isFloat32Array(new Float32Array()); // Returns true
1542
+ * util.types.isFloat32Array(new Float64Array()); // Returns false
1543
+ * ```
1544
+ * @since v10.0.0
1545
+ */
1546
+ function isFloat32Array(object: unknown): object is Float32Array;
1547
+ /**
1548
+ * Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance.
1549
+ *
1550
+ * ```js
1551
+ * util.types.isFloat64Array(new ArrayBuffer()); // Returns false
1552
+ * util.types.isFloat64Array(new Uint8Array()); // Returns false
1553
+ * util.types.isFloat64Array(new Float64Array()); // Returns true
1554
+ * ```
1555
+ * @since v10.0.0
1556
+ */
1557
+ function isFloat64Array(object: unknown): object is Float64Array;
1558
+ /**
1559
+ * Returns `true` if the value is a generator function.
1560
+ * This only reports back what the JavaScript engine is seeing;
1561
+ * in particular, the return value may not match the original source code if
1562
+ * a transpilation tool was used.
1563
+ *
1564
+ * ```js
1565
+ * util.types.isGeneratorFunction(function foo() {}); // Returns false
1566
+ * util.types.isGeneratorFunction(function* foo() {}); // Returns true
1567
+ * ```
1568
+ * @since v10.0.0
1569
+ */
1570
+ function isGeneratorFunction(object: unknown): object is GeneratorFunction;
1571
+ /**
1572
+ * Returns `true` if the value is a generator object as returned from a
1573
+ * built-in generator function.
1574
+ * This only reports back what the JavaScript engine is seeing;
1575
+ * in particular, the return value may not match the original source code if
1576
+ * a transpilation tool was used.
1577
+ *
1578
+ * ```js
1579
+ * function* foo() {}
1580
+ * const generator = foo();
1581
+ * util.types.isGeneratorObject(generator); // Returns true
1582
+ * ```
1583
+ * @since v10.0.0
1584
+ */
1585
+ function isGeneratorObject(object: unknown): object is Generator;
1586
+ /**
1587
+ * Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance.
1588
+ *
1589
+ * ```js
1590
+ * util.types.isInt8Array(new ArrayBuffer()); // Returns false
1591
+ * util.types.isInt8Array(new Int8Array()); // Returns true
1592
+ * util.types.isInt8Array(new Float64Array()); // Returns false
1593
+ * ```
1594
+ * @since v10.0.0
1595
+ */
1596
+ function isInt8Array(object: unknown): object is Int8Array;
1597
+ /**
1598
+ * Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance.
1599
+ *
1600
+ * ```js
1601
+ * util.types.isInt16Array(new ArrayBuffer()); // Returns false
1602
+ * util.types.isInt16Array(new Int16Array()); // Returns true
1603
+ * util.types.isInt16Array(new Float64Array()); // Returns false
1604
+ * ```
1605
+ * @since v10.0.0
1606
+ */
1607
+ function isInt16Array(object: unknown): object is Int16Array;
1608
+ /**
1609
+ * Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance.
1610
+ *
1611
+ * ```js
1612
+ * util.types.isInt32Array(new ArrayBuffer()); // Returns false
1613
+ * util.types.isInt32Array(new Int32Array()); // Returns true
1614
+ * util.types.isInt32Array(new Float64Array()); // Returns false
1615
+ * ```
1616
+ * @since v10.0.0
1617
+ */
1618
+ function isInt32Array(object: unknown): object is Int32Array;
1619
+ /**
1620
+ * Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
1621
+ *
1622
+ * ```js
1623
+ * util.types.isMap(new Map()); // Returns true
1624
+ * ```
1625
+ * @since v10.0.0
1626
+ */
1627
+ function isMap<T>(object: T | {}): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>) : Map<unknown, unknown>;
1628
+ /**
1629
+ * 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.
1630
+ *
1631
+ * ```js
1632
+ * const map = new Map();
1633
+ * util.types.isMapIterator(map.keys()); // Returns true
1634
+ * util.types.isMapIterator(map.values()); // Returns true
1635
+ * util.types.isMapIterator(map.entries()); // Returns true
1636
+ * util.types.isMapIterator(map[Symbol.iterator]()); // Returns true
1637
+ * ```
1638
+ * @since v10.0.0
1639
+ */
1640
+ function isMapIterator(object: unknown): boolean;
1641
+ /**
1642
+ * Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects).
1643
+ *
1644
+ * ```js
1645
+ * import * as ns from './a.js';
1646
+ *
1647
+ * util.types.isModuleNamespaceObject(ns); // Returns true
1648
+ * ```
1649
+ * @since v10.0.0
1650
+ */
1651
+ function isModuleNamespaceObject(value: unknown): boolean;
1652
+ /**
1653
+ * Returns `true` if the value is an instance of a built-in `Error` type.
1654
+ *
1655
+ * ```js
1656
+ * util.types.isNativeError(new Error()); // Returns true
1657
+ * util.types.isNativeError(new TypeError()); // Returns true
1658
+ * util.types.isNativeError(new RangeError()); // Returns true
1659
+ * ```
1660
+ * @since v10.0.0
1661
+ */
1662
+ function isNativeError(object: unknown): object is Error;
1663
+ /**
1664
+ * Returns `true` if the value is a number object, e.g. created
1665
+ * by `new Number()`.
1666
+ *
1667
+ * ```js
1668
+ * util.types.isNumberObject(0); // Returns false
1669
+ * util.types.isNumberObject(new Number(0)); // Returns true
1670
+ * ```
1671
+ * @since v10.0.0
1672
+ */
1673
+ function isNumberObject(object: unknown): object is Number;
1674
+ /**
1675
+ * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
1676
+ *
1677
+ * ```js
1678
+ * util.types.isPromise(Promise.resolve(42)); // Returns true
1679
+ * ```
1680
+ * @since v10.0.0
1681
+ */
1682
+ function isPromise(object: unknown): object is Promise<unknown>;
1683
+ /**
1684
+ * Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance.
1685
+ *
1686
+ * ```js
1687
+ * const target = {};
1688
+ * const proxy = new Proxy(target, {});
1689
+ * util.types.isProxy(target); // Returns false
1690
+ * util.types.isProxy(proxy); // Returns true
1691
+ * ```
1692
+ * @since v10.0.0
1693
+ */
1694
+ function isProxy(object: unknown): boolean;
1695
+ /**
1696
+ * Returns `true` if the value is a regular expression object.
1697
+ *
1698
+ * ```js
1699
+ * util.types.isRegExp(/abc/); // Returns true
1700
+ * util.types.isRegExp(new RegExp('abc')); // Returns true
1701
+ * ```
1702
+ * @since v10.0.0
1703
+ */
1704
+ function isRegExp(object: unknown): object is RegExp;
1705
+ /**
1706
+ * Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
1707
+ *
1708
+ * ```js
1709
+ * util.types.isSet(new Set()); // Returns true
1710
+ * ```
1711
+ * @since v10.0.0
1712
+ */
1713
+ function isSet<T>(object: T | {}): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
1714
+ /**
1715
+ * 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.
1716
+ *
1717
+ * ```js
1718
+ * const set = new Set();
1719
+ * util.types.isSetIterator(set.keys()); // Returns true
1720
+ * util.types.isSetIterator(set.values()); // Returns true
1721
+ * util.types.isSetIterator(set.entries()); // Returns true
1722
+ * util.types.isSetIterator(set[Symbol.iterator]()); // Returns true
1723
+ * ```
1724
+ * @since v10.0.0
1725
+ */
1726
+ function isSetIterator(object: unknown): boolean;
1727
+ /**
1728
+ * Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1729
+ * This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is
1730
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1731
+ *
1732
+ * ```js
1733
+ * util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false
1734
+ * util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true
1735
+ * ```
1736
+ * @since v10.0.0
1737
+ */
1738
+ function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
1739
+ /**
1740
+ * Returns `true` if the value is a string object, e.g. created
1741
+ * by `new String()`.
1742
+ *
1743
+ * ```js
1744
+ * util.types.isStringObject('foo'); // Returns false
1745
+ * util.types.isStringObject(new String('foo')); // Returns true
1746
+ * ```
1747
+ * @since v10.0.0
1748
+ */
1749
+ function isStringObject(object: unknown): object is String;
1750
+ /**
1751
+ * Returns `true` if the value is a symbol object, created
1752
+ * by calling `Object()` on a `Symbol` primitive.
1753
+ *
1754
+ * ```js
1755
+ * const symbol = Symbol('foo');
1756
+ * util.types.isSymbolObject(symbol); // Returns false
1757
+ * util.types.isSymbolObject(Object(symbol)); // Returns true
1758
+ * ```
1759
+ * @since v10.0.0
1760
+ */
1761
+ function isSymbolObject(object: unknown): object is Symbol;
1762
+ /**
1763
+ * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
1764
+ *
1765
+ * ```js
1766
+ * util.types.isTypedArray(new ArrayBuffer()); // Returns false
1767
+ * util.types.isTypedArray(new Uint8Array()); // Returns true
1768
+ * util.types.isTypedArray(new Float64Array()); // Returns true
1769
+ * ```
1770
+ *
1771
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1772
+ * @since v10.0.0
1773
+ */
1774
+ function isTypedArray(object: unknown): object is NodeJS.TypedArray;
1775
+ /**
1776
+ * Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance.
1777
+ *
1778
+ * ```js
1779
+ * util.types.isUint8Array(new ArrayBuffer()); // Returns false
1780
+ * util.types.isUint8Array(new Uint8Array()); // Returns true
1781
+ * util.types.isUint8Array(new Float64Array()); // Returns false
1782
+ * ```
1783
+ * @since v10.0.0
1784
+ */
1785
+ function isUint8Array(object: unknown): object is Uint8Array;
1786
+ /**
1787
+ * Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance.
1788
+ *
1789
+ * ```js
1790
+ * util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
1791
+ * util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true
1792
+ * util.types.isUint8ClampedArray(new Float64Array()); // Returns false
1793
+ * ```
1794
+ * @since v10.0.0
1795
+ */
1796
+ function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
1797
+ /**
1798
+ * Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance.
1799
+ *
1800
+ * ```js
1801
+ * util.types.isUint16Array(new ArrayBuffer()); // Returns false
1802
+ * util.types.isUint16Array(new Uint16Array()); // Returns true
1803
+ * util.types.isUint16Array(new Float64Array()); // Returns false
1804
+ * ```
1805
+ * @since v10.0.0
1806
+ */
1807
+ function isUint16Array(object: unknown): object is Uint16Array;
1808
+ /**
1809
+ * Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance.
1810
+ *
1811
+ * ```js
1812
+ * util.types.isUint32Array(new ArrayBuffer()); // Returns false
1813
+ * util.types.isUint32Array(new Uint32Array()); // Returns true
1814
+ * util.types.isUint32Array(new Float64Array()); // Returns false
1815
+ * ```
1816
+ * @since v10.0.0
1817
+ */
1818
+ function isUint32Array(object: unknown): object is Uint32Array;
1819
+ /**
1820
+ * Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance.
1821
+ *
1822
+ * ```js
1823
+ * util.types.isWeakMap(new WeakMap()); // Returns true
1824
+ * ```
1825
+ * @since v10.0.0
1826
+ */
1827
+ function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
1828
+ /**
1829
+ * Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance.
1830
+ *
1831
+ * ```js
1832
+ * util.types.isWeakSet(new WeakSet()); // Returns true
1833
+ * ```
1834
+ * @since v10.0.0
1835
+ */
1836
+ function isWeakSet(object: unknown): object is WeakSet<object>;
1837
+ /**
1838
+ * Returns `true` if `value` is a `KeyObject`, `false` otherwise.
1839
+ * @since v16.2.0
1840
+ */
1841
+ function isKeyObject(object: unknown): object is KeyObject;
1842
+ /**
1843
+ * Returns `true` if `value` is a `CryptoKey`, `false` otherwise.
1844
+ * @since v16.2.0
1845
+ */
1846
+ function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
1847
+ }
1848
+ declare module 'node:util' {
1849
+ export * from 'util';
1850
+ }
1851
+ declare module 'node:util/types' {
1852
+ export * from 'util/types';
1853
+ }