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