zai-fca 1.0.5

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.

Potentially problematic release.


This version of zai-fca might be problematic. Click here for more details.

Files changed (185) hide show
  1. package/.cache/replit/env/latest +56 -0
  2. package/.cache/replit/env/latest.json +1 -0
  3. package/.cache/replit/modules/nodejs-20.res +1 -0
  4. package/.cache/replit/modules/replit.res +1 -0
  5. package/.cache/replit/modules.stamp +0 -0
  6. package/.cache/typescript/5.6/node_modules/.package-lock.json +40 -0
  7. package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +21 -0
  8. package/.cache/typescript/5.6/node_modules/@types/node/README.md +15 -0
  9. package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +8 -0
  10. package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +1040 -0
  11. package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +541 -0
  12. package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +385 -0
  13. package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +1933 -0
  14. package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +1549 -0
  15. package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +579 -0
  16. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
  17. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +9 -0
  18. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +23 -0
  19. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  20. package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +452 -0
  21. package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +19 -0
  22. package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +4475 -0
  23. package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +596 -0
  24. package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  25. package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +476 -0
  26. package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +865 -0
  27. package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +124 -0
  28. package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +170 -0
  29. package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +931 -0
  30. package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +1275 -0
  31. package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +4396 -0
  32. package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +566 -0
  33. package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  34. package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +1958 -0
  35. package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +2558 -0
  36. package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +543 -0
  37. package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +92 -0
  38. package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +3966 -0
  39. package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +402 -0
  40. package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +1001 -0
  41. package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +495 -0
  42. package/.cache/typescript/5.6/node_modules/@types/node/package.json +220 -0
  43. package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +200 -0
  44. package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +965 -0
  45. package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +1963 -0
  46. package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +117 -0
  47. package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +153 -0
  48. package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +162 -0
  49. package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +589 -0
  50. package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +430 -0
  51. package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +153 -0
  52. package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +213 -0
  53. package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +12 -0
  54. package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +90 -0
  55. package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +609 -0
  56. package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +1726 -0
  57. package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +67 -0
  58. package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +2248 -0
  59. package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +97 -0
  60. package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +240 -0
  61. package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +1226 -0
  62. package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +197 -0
  63. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +385 -0
  64. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  65. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +92 -0
  66. package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +208 -0
  67. package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +972 -0
  68. package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +2371 -0
  69. package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +808 -0
  70. package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +976 -0
  71. package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +181 -0
  72. package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +745 -0
  73. package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +539 -0
  74. package/.cache/typescript/5.6/node_modules/@types/npmlog/LICENSE +21 -0
  75. package/.cache/typescript/5.6/node_modules/@types/npmlog/README.md +15 -0
  76. package/.cache/typescript/5.6/node_modules/@types/npmlog/index.d.ts +84 -0
  77. package/.cache/typescript/5.6/node_modules/@types/npmlog/package.json +32 -0
  78. package/.cache/typescript/5.6/node_modules/types-registry/README.md +2 -0
  79. package/.cache/typescript/5.6/node_modules/types-registry/index.json +1 -0
  80. package/.cache/typescript/5.6/node_modules/types-registry/package.json +20 -0
  81. package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +21 -0
  82. package/.cache/typescript/5.6/node_modules/undici-types/README.md +6 -0
  83. package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +31 -0
  84. package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +43 -0
  85. package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +29 -0
  86. package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +36 -0
  87. package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +108 -0
  88. package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +34 -0
  89. package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +21 -0
  90. package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +28 -0
  91. package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
  92. package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +255 -0
  93. package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
  94. package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +149 -0
  95. package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +61 -0
  96. package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +209 -0
  97. package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +39 -0
  98. package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +54 -0
  99. package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +108 -0
  100. package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  101. package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +7 -0
  102. package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +15 -0
  103. package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +4 -0
  104. package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +71 -0
  105. package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +17 -0
  106. package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +50 -0
  107. package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +25 -0
  108. package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +12 -0
  109. package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  110. package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +25 -0
  111. package/.cache/typescript/5.6/node_modules/undici-types/package.json +55 -0
  112. package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +33 -0
  113. package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +19 -0
  114. package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +39 -0
  115. package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +28 -0
  116. package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +60 -0
  117. package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +8 -0
  118. package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +116 -0
  119. package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +18 -0
  120. package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +222 -0
  121. package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +150 -0
  122. package/.cache/typescript/5.6/package-lock.json +48 -0
  123. package/.cache/typescript/5.6/package.json +1 -0
  124. package/.replit +4 -0
  125. package/.upm/store.json +1 -0
  126. package/README.md +289 -0
  127. package/index.js +460 -0
  128. package/package.json +30 -0
  129. package/src/Screenshot.js +83 -0
  130. package/src/addExternalModule.js +15 -0
  131. package/src/addUserToGroup.js +77 -0
  132. package/src/changeAdminStatus.js +47 -0
  133. package/src/changeArchivedStatus.js +41 -0
  134. package/src/changeAvt.js +85 -0
  135. package/src/changeBio.js +65 -0
  136. package/src/changeBlockedStatus.js +36 -0
  137. package/src/changeGroupImage.js +106 -0
  138. package/src/changeNickname.js +45 -0
  139. package/src/changeThreadColor.js +61 -0
  140. package/src/changeThreadEmoji.js +41 -0
  141. package/src/createNewGroup.js +70 -0
  142. package/src/createPoll.js +59 -0
  143. package/src/createPost.js +277 -0
  144. package/src/deleteMessage.js +44 -0
  145. package/src/deleteThread.js +42 -0
  146. package/src/forwardAttachment.js +47 -0
  147. package/src/getCurrentUserID.js +7 -0
  148. package/src/getEmojiUrl.js +27 -0
  149. package/src/getFriendsList.js +73 -0
  150. package/src/getThreadHistory.js +537 -0
  151. package/src/getThreadHistoryDeprecated.js +71 -0
  152. package/src/getThreadInfo.js +232 -0
  153. package/src/getThreadInfoDeprecated.js +56 -0
  154. package/src/getThreadList.js +213 -0
  155. package/src/getThreadListDeprecated.js +46 -0
  156. package/src/getThreadPictures.js +59 -0
  157. package/src/getUID.js +119 -0
  158. package/src/getUserID.js +61 -0
  159. package/src/getUserInfo.js +66 -0
  160. package/src/handleFriendRequest.js +46 -0
  161. package/src/handleMessageRequest.js +47 -0
  162. package/src/httpGet.js +49 -0
  163. package/src/httpPost.js +48 -0
  164. package/src/listenMqtt.js +827 -0
  165. package/src/listenMqtt.txt +827 -0
  166. package/src/logout.js +68 -0
  167. package/src/markAsDelivered.js +47 -0
  168. package/src/markAsRead.js +70 -0
  169. package/src/markAsReadAll.js +40 -0
  170. package/src/markAsSeen.js +48 -0
  171. package/src/muteThread.js +45 -0
  172. package/src/postFormData.txt +46 -0
  173. package/src/removeUserFromGroup.js +45 -0
  174. package/src/resolvePhotoUrl.js +36 -0
  175. package/src/searchForThread.js +42 -0
  176. package/src/sendMessage.js +329 -0
  177. package/src/sendTypingIndicator.js +70 -0
  178. package/src/setMessageReaction.js +109 -0
  179. package/src/setPostReaction.js +102 -0
  180. package/src/setTitle.js +70 -0
  181. package/src/shareContact.js +46 -0
  182. package/src/shareLink.js +62 -0
  183. package/src/threadColors.js +41 -0
  184. package/src/unfriend.js +42 -0
  185. package/src/unsendMessage.js +39 -0
@@ -0,0 +1,2371 @@
1
+ /**
2
+ * The `node:util` module supports the needs of Node.js internal APIs. Many of the
3
+ * utilities are useful for application and module developers as well. To access
4
+ * it:
5
+ *
6
+ * ```js
7
+ * import util from 'node:util';
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/util.js)
10
+ */
11
+ declare module "util" {
12
+ import * as types from "node:util/types";
13
+ export interface InspectOptions {
14
+ /**
15
+ * If `true`, object's non-enumerable symbols and properties are included in the formatted result.
16
+ * `WeakMap` and `WeakSet` entries are also included as well as user defined prototype properties (excluding method properties).
17
+ * @default false
18
+ */
19
+ showHidden?: boolean | undefined;
20
+ /**
21
+ * Specifies the number of times to recurse while formatting object.
22
+ * This is useful for inspecting large objects.
23
+ * To recurse up to the maximum call stack size pass `Infinity` or `null`.
24
+ * @default 2
25
+ */
26
+ depth?: number | null | undefined;
27
+ /**
28
+ * If `true`, the output is styled with ANSI color codes. Colors are customizable.
29
+ */
30
+ colors?: boolean | undefined;
31
+ /**
32
+ * If `false`, `[util.inspect.custom](depth, opts, inspect)` functions are not invoked.
33
+ * @default true
34
+ */
35
+ customInspect?: boolean | undefined;
36
+ /**
37
+ * If `true`, `Proxy` inspection includes the target and handler objects.
38
+ * @default false
39
+ */
40
+ showProxy?: boolean | undefined;
41
+ /**
42
+ * Specifies the maximum number of `Array`, `TypedArray`, `WeakMap`, and `WeakSet` elements
43
+ * to include when formatting. Set to `null` or `Infinity` to show all elements.
44
+ * Set to `0` or negative to show no elements.
45
+ * @default 100
46
+ */
47
+ maxArrayLength?: number | null | undefined;
48
+ /**
49
+ * Specifies the maximum number of characters to
50
+ * include when formatting. Set to `null` or `Infinity` to show all elements.
51
+ * Set to `0` or negative to show no characters.
52
+ * @default 10000
53
+ */
54
+ maxStringLength?: number | null | undefined;
55
+ /**
56
+ * The length at which input values are split across multiple lines.
57
+ * Set to `Infinity` to format the input as a single line
58
+ * (in combination with `compact` set to `true` or any number >= `1`).
59
+ * @default 80
60
+ */
61
+ breakLength?: number | undefined;
62
+ /**
63
+ * Setting this to `false` causes each object key
64
+ * to be displayed on a new line. It will also add new lines to text that is
65
+ * longer than `breakLength`. If set to a number, the most `n` inner elements
66
+ * are united on a single line as long as all properties fit into
67
+ * `breakLength`. Short array elements are also grouped together. Note that no
68
+ * text will be reduced below 16 characters, no matter the `breakLength` size.
69
+ * For more information, see the example below.
70
+ * @default true
71
+ */
72
+ compact?: boolean | number | undefined;
73
+ /**
74
+ * If set to `true` or a function, all properties of an object, and `Set` and `Map`
75
+ * entries are sorted in the resulting string.
76
+ * If set to `true` the default sort is used.
77
+ * If set to a function, it is used as a compare function.
78
+ */
79
+ sorted?: boolean | ((a: string, b: string) => number) | undefined;
80
+ /**
81
+ * If set to `true`, getters are going to be
82
+ * inspected as well. If set to `'get'` only getters without setter are going
83
+ * to be inspected. If set to `'set'` only getters having a corresponding
84
+ * setter are going to be inspected. This might cause side effects depending on
85
+ * the getter function.
86
+ * @default false
87
+ */
88
+ getters?: "get" | "set" | boolean | undefined;
89
+ /**
90
+ * If set to `true`, an underscore is used to separate every three digits in all bigints and numbers.
91
+ * @default false
92
+ */
93
+ numericSeparator?: boolean | undefined;
94
+ }
95
+ export type Style =
96
+ | "special"
97
+ | "number"
98
+ | "bigint"
99
+ | "boolean"
100
+ | "undefined"
101
+ | "null"
102
+ | "string"
103
+ | "symbol"
104
+ | "date"
105
+ | "regexp"
106
+ | "module";
107
+ export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect
108
+ export interface InspectOptionsStylized extends InspectOptions {
109
+ stylize(text: string, styleType: Style): string;
110
+ }
111
+ export interface StacktraceObject {
112
+ /**
113
+ * Returns the name of the function associated with this stack frame.
114
+ */
115
+ functionName: string;
116
+ /**
117
+ * Returns the name of the resource that contains the script for the
118
+ * function for this StackFrame.
119
+ */
120
+ scriptName: string;
121
+ /**
122
+ * Returns the number, 1-based, of the line for the associate function call.
123
+ */
124
+ lineNumber: number;
125
+ /**
126
+ * Returns the 1-based column offset on the line for the associated function call.
127
+ */
128
+ column: number;
129
+ }
130
+ /**
131
+ * The `util.format()` method returns a formatted string using the first argument
132
+ * as a `printf`-like format string which can contain zero or more format
133
+ * specifiers. Each specifier is replaced with the converted value from the
134
+ * corresponding argument. Supported specifiers are:
135
+ *
136
+ * If a specifier does not have a corresponding argument, it is not replaced:
137
+ *
138
+ * ```js
139
+ * util.format('%s:%s', 'foo');
140
+ * // Returns: 'foo:%s'
141
+ * ```
142
+ *
143
+ * Values that are not part of the format string are formatted using `util.inspect()` if their type is not `string`.
144
+ *
145
+ * If there are more arguments passed to the `util.format()` method than the
146
+ * number of specifiers, the extra arguments are concatenated to the returned
147
+ * string, separated by spaces:
148
+ *
149
+ * ```js
150
+ * util.format('%s:%s', 'foo', 'bar', 'baz');
151
+ * // Returns: 'foo:bar baz'
152
+ * ```
153
+ *
154
+ * 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:
155
+ *
156
+ * ```js
157
+ * util.format(1, 2, 3);
158
+ * // Returns: '1 2 3'
159
+ * ```
160
+ *
161
+ * If only one argument is passed to `util.format()`, it is returned as it is
162
+ * without any formatting:
163
+ *
164
+ * ```js
165
+ * util.format('%% %s');
166
+ * // Returns: '%% %s'
167
+ * ```
168
+ *
169
+ * `util.format()` is a synchronous method that is intended as a debugging tool.
170
+ * Some input values can have a significant performance overhead that can block the
171
+ * event loop. Use this function with care and never in a hot code path.
172
+ * @since v0.5.3
173
+ * @param format A `printf`-like format string.
174
+ */
175
+ export function format(format?: any, ...param: any[]): string;
176
+ /**
177
+ * This function is identical to {@link format}, except in that it takes
178
+ * an `inspectOptions` argument which specifies options that are passed along to {@link inspect}.
179
+ *
180
+ * ```js
181
+ * util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 });
182
+ * // Returns 'See object { foo: 42 }', where `42` is colored as a number
183
+ * // when printed to a terminal.
184
+ * ```
185
+ * @since v10.0.0
186
+ */
187
+ export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
188
+ /**
189
+ * Returns an array of stacktrace objects containing the stack of
190
+ * the caller function.
191
+ *
192
+ * ```js
193
+ * const util = require('node:util');
194
+ *
195
+ * function exampleFunction() {
196
+ * const callSites = util.getCallSite();
197
+ *
198
+ * console.log('Call Sites:');
199
+ * callSites.forEach((callSite, index) => {
200
+ * console.log(`CallSite ${index + 1}:`);
201
+ * console.log(`Function Name: ${callSite.functionName}`);
202
+ * console.log(`Script Name: ${callSite.scriptName}`);
203
+ * console.log(`Line Number: ${callSite.lineNumber}`);
204
+ * console.log(`Column Number: ${callSite.column}`);
205
+ * });
206
+ * // CallSite 1:
207
+ * // Function Name: exampleFunction
208
+ * // Script Name: /home/example.js
209
+ * // Line Number: 5
210
+ * // Column Number: 26
211
+ *
212
+ * // CallSite 2:
213
+ * // Function Name: anotherFunction
214
+ * // Script Name: /home/example.js
215
+ * // Line Number: 22
216
+ * // Column Number: 3
217
+ *
218
+ * // ...
219
+ * }
220
+ *
221
+ * // A function to simulate another stack layer
222
+ * function anotherFunction() {
223
+ * exampleFunction();
224
+ * }
225
+ *
226
+ * anotherFunction();
227
+ * ```
228
+ * @param frames Number of frames returned in the stacktrace.
229
+ * **Default:** `10`. Allowable range is between 1 and 200.
230
+ * @return An array of stacktrace objects
231
+ * @since v22.9.0
232
+ */
233
+ export function getCallSite(frames?: number): StacktraceObject[];
234
+ /**
235
+ * Returns the string name for a numeric error code that comes from a Node.js API.
236
+ * The mapping between error codes and error names is platform-dependent.
237
+ * See `Common System Errors` for the names of common errors.
238
+ *
239
+ * ```js
240
+ * fs.access('file/that/does/not/exist', (err) => {
241
+ * const name = util.getSystemErrorName(err.errno);
242
+ * console.error(name); // ENOENT
243
+ * });
244
+ * ```
245
+ * @since v9.7.0
246
+ */
247
+ export function getSystemErrorName(err: number): string;
248
+ /**
249
+ * Returns a Map of all system error codes available from the Node.js API.
250
+ * The mapping between error codes and error names is platform-dependent.
251
+ * See `Common System Errors` for the names of common errors.
252
+ *
253
+ * ```js
254
+ * fs.access('file/that/does/not/exist', (err) => {
255
+ * const errorMap = util.getSystemErrorMap();
256
+ * const name = errorMap.get(err.errno);
257
+ * console.error(name); // ENOENT
258
+ * });
259
+ * ```
260
+ * @since v16.0.0, v14.17.0
261
+ */
262
+ export function getSystemErrorMap(): Map<number, [string, string]>;
263
+ /**
264
+ * The `util.log()` method prints the given `string` to `stdout` with an included
265
+ * timestamp.
266
+ *
267
+ * ```js
268
+ * import util from 'node:util';
269
+ *
270
+ * util.log('Timestamped message.');
271
+ * ```
272
+ * @since v0.3.0
273
+ * @deprecated Since v6.0.0 - Use a third party module instead.
274
+ */
275
+ export function log(string: string): void;
276
+ /**
277
+ * Returns the `string` after replacing any surrogate code points
278
+ * (or equivalently, any unpaired surrogate code units) with the
279
+ * Unicode "replacement character" U+FFFD.
280
+ * @since v16.8.0, v14.18.0
281
+ */
282
+ export function toUSVString(string: string): string;
283
+ /**
284
+ * Creates and returns an `AbortController` instance whose `AbortSignal` is marked
285
+ * as transferable and can be used with `structuredClone()` or `postMessage()`.
286
+ * @since v18.11.0
287
+ * @experimental
288
+ * @returns A transferable AbortController
289
+ */
290
+ export function transferableAbortController(): AbortController;
291
+ /**
292
+ * Marks the given `AbortSignal` as transferable so that it can be used with`structuredClone()` and `postMessage()`.
293
+ *
294
+ * ```js
295
+ * const signal = transferableAbortSignal(AbortSignal.timeout(100));
296
+ * const channel = new MessageChannel();
297
+ * channel.port2.postMessage(signal, [signal]);
298
+ * ```
299
+ * @since v18.11.0
300
+ * @experimental
301
+ * @param signal The AbortSignal
302
+ * @returns The same AbortSignal
303
+ */
304
+ export function transferableAbortSignal(signal: AbortSignal): AbortSignal;
305
+ /**
306
+ * Listens to abort event on the provided `signal` and
307
+ * returns a promise that is fulfilled when the `signal` is
308
+ * aborted. If the passed `resource` is garbage collected before the `signal` is
309
+ * aborted, the returned promise shall remain pending indefinitely.
310
+ *
311
+ * ```js
312
+ * import { aborted } from 'node:util';
313
+ *
314
+ * const dependent = obtainSomethingAbortable();
315
+ *
316
+ * aborted(dependent.signal, dependent).then(() => {
317
+ * // Do something when dependent is aborted.
318
+ * });
319
+ *
320
+ * dependent.on('event', () => {
321
+ * dependent.abort();
322
+ * });
323
+ * ```
324
+ * @since v19.7.0
325
+ * @experimental
326
+ * @param resource Any non-null entity, reference to which is held weakly.
327
+ */
328
+ export function aborted(signal: AbortSignal, resource: any): Promise<void>;
329
+ /**
330
+ * The `util.inspect()` method returns a string representation of `object` that is
331
+ * intended for debugging. The output of `util.inspect` may change at any time
332
+ * and should not be depended upon programmatically. Additional `options` may be
333
+ * passed that alter the result. `util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
334
+ * an identifiable tag for an inspected value.
335
+ *
336
+ * ```js
337
+ * class Foo {
338
+ * get [Symbol.toStringTag]() {
339
+ * return 'bar';
340
+ * }
341
+ * }
342
+ *
343
+ * class Bar {}
344
+ *
345
+ * const baz = Object.create(null, { [Symbol.toStringTag]: { value: 'foo' } });
346
+ *
347
+ * util.inspect(new Foo()); // 'Foo [bar] {}'
348
+ * util.inspect(new Bar()); // 'Bar {}'
349
+ * util.inspect(baz); // '[foo] {}'
350
+ * ```
351
+ *
352
+ * Circular references point to their anchor by using a reference index:
353
+ *
354
+ * ```js
355
+ * import { inspect } from 'node:util';
356
+ *
357
+ * const obj = {};
358
+ * obj.a = [obj];
359
+ * obj.b = {};
360
+ * obj.b.inner = obj.b;
361
+ * obj.b.obj = obj;
362
+ *
363
+ * console.log(inspect(obj));
364
+ * // <ref *1> {
365
+ * // a: [ [Circular *1] ],
366
+ * // b: <ref *2> { inner: [Circular *2], obj: [Circular *1] }
367
+ * // }
368
+ * ```
369
+ *
370
+ * The following example inspects all properties of the `util` object:
371
+ *
372
+ * ```js
373
+ * import util from 'node:util';
374
+ *
375
+ * console.log(util.inspect(util, { showHidden: true, depth: null }));
376
+ * ```
377
+ *
378
+ * The following example highlights the effect of the `compact` option:
379
+ *
380
+ * ```js
381
+ * import util from 'node:util';
382
+ *
383
+ * const o = {
384
+ * a: [1, 2, [[
385
+ * 'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' +
386
+ * 'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
387
+ * 'test',
388
+ * 'foo']], 4],
389
+ * b: new Map([['za', 1], ['zb', 'test']]),
390
+ * };
391
+ * console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
392
+ *
393
+ * // { a:
394
+ * // [ 1,
395
+ * // 2,
396
+ * // [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line
397
+ * // 'test',
398
+ * // 'foo' ] ],
399
+ * // 4 ],
400
+ * // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
401
+ *
402
+ * // Setting `compact` to false or an integer creates more reader friendly output.
403
+ * console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
404
+ *
405
+ * // {
406
+ * // a: [
407
+ * // 1,
408
+ * // 2,
409
+ * // [
410
+ * // [
411
+ * // 'Lorem ipsum dolor sit amet,\n' +
412
+ * // 'consectetur adipiscing elit, sed do eiusmod \n' +
413
+ * // 'tempor incididunt ut labore et dolore magna aliqua.',
414
+ * // 'test',
415
+ * // 'foo'
416
+ * // ]
417
+ * // ],
418
+ * // 4
419
+ * // ],
420
+ * // b: Map(2) {
421
+ * // 'za' => 1,
422
+ * // 'zb' => 'test'
423
+ * // }
424
+ * // }
425
+ *
426
+ * // Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a
427
+ * // single line.
428
+ * ```
429
+ *
430
+ * The `showHidden` option allows [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) and
431
+ * [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be
432
+ * inspected. If there are more entries than `maxArrayLength`, there is no
433
+ * 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
434
+ * result in different output. Furthermore, entries
435
+ * with no remaining strong references may be garbage collected at any time.
436
+ *
437
+ * ```js
438
+ * import { inspect } from 'node:util';
439
+ *
440
+ * const obj = { a: 1 };
441
+ * const obj2 = { b: 2 };
442
+ * const weakSet = new WeakSet([obj, obj2]);
443
+ *
444
+ * console.log(inspect(weakSet, { showHidden: true }));
445
+ * // WeakSet { { a: 1 }, { b: 2 } }
446
+ * ```
447
+ *
448
+ * The `sorted` option ensures that an object's property insertion order does not
449
+ * impact the result of `util.inspect()`.
450
+ *
451
+ * ```js
452
+ * import { inspect } from 'node:util';
453
+ * import assert from 'node:assert';
454
+ *
455
+ * const o1 = {
456
+ * b: [2, 3, 1],
457
+ * a: '`a` comes before `b`',
458
+ * c: new Set([2, 3, 1]),
459
+ * };
460
+ * console.log(inspect(o1, { sorted: true }));
461
+ * // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set(3) { 1, 2, 3 } }
462
+ * console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) }));
463
+ * // { c: Set(3) { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' }
464
+ *
465
+ * const o2 = {
466
+ * c: new Set([2, 1, 3]),
467
+ * a: '`a` comes before `b`',
468
+ * b: [2, 3, 1],
469
+ * };
470
+ * assert.strict.equal(
471
+ * inspect(o1, { sorted: true }),
472
+ * inspect(o2, { sorted: true }),
473
+ * );
474
+ * ```
475
+ *
476
+ * The `numericSeparator` option adds an underscore every three digits to all
477
+ * numbers.
478
+ *
479
+ * ```js
480
+ * import { inspect } from 'node:util';
481
+ *
482
+ * const thousand = 1_000;
483
+ * const million = 1_000_000;
484
+ * const bigNumber = 123_456_789n;
485
+ * const bigDecimal = 1_234.123_45;
486
+ *
487
+ * console.log(inspect(thousand, { numericSeparator: true }));
488
+ * // 1_000
489
+ * console.log(inspect(million, { numericSeparator: true }));
490
+ * // 1_000_000
491
+ * console.log(inspect(bigNumber, { numericSeparator: true }));
492
+ * // 123_456_789n
493
+ * console.log(inspect(bigDecimal, { numericSeparator: true }));
494
+ * // 1_234.123_45
495
+ * ```
496
+ *
497
+ * `util.inspect()` is a synchronous method intended for debugging. Its maximum
498
+ * output length is approximately 128 MiB. Inputs that result in longer output will
499
+ * be truncated.
500
+ * @since v0.3.0
501
+ * @param object Any JavaScript primitive or `Object`.
502
+ * @return The representation of `object`.
503
+ */
504
+ export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
505
+ export function inspect(object: any, options?: InspectOptions): string;
506
+ export namespace inspect {
507
+ let colors: NodeJS.Dict<[number, number]>;
508
+ let styles: {
509
+ [K in Style]: string;
510
+ };
511
+ let defaultOptions: InspectOptions;
512
+ /**
513
+ * Allows changing inspect settings from the repl.
514
+ */
515
+ let replDefaults: InspectOptions;
516
+ /**
517
+ * That can be used to declare custom inspect functions.
518
+ */
519
+ const custom: unique symbol;
520
+ }
521
+ /**
522
+ * Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
523
+ *
524
+ * Returns `true` if the given `object` is an `Array`. Otherwise, returns `false`.
525
+ *
526
+ * ```js
527
+ * import util from 'node:util';
528
+ *
529
+ * util.isArray([]);
530
+ * // Returns: true
531
+ * util.isArray(new Array());
532
+ * // Returns: true
533
+ * util.isArray({});
534
+ * // Returns: false
535
+ * ```
536
+ * @since v0.6.0
537
+ * @deprecated Since v4.0.0 - Use `isArray` instead.
538
+ */
539
+ export function isArray(object: unknown): object is unknown[];
540
+ /**
541
+ * Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
542
+ *
543
+ * ```js
544
+ * import util from 'node:util';
545
+ *
546
+ * util.isRegExp(/some regexp/);
547
+ * // Returns: true
548
+ * util.isRegExp(new RegExp('another regexp'));
549
+ * // Returns: true
550
+ * util.isRegExp({});
551
+ * // Returns: false
552
+ * ```
553
+ * @since v0.6.0
554
+ * @deprecated Since v4.0.0 - Deprecated
555
+ */
556
+ export function isRegExp(object: unknown): object is RegExp;
557
+ /**
558
+ * Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
559
+ *
560
+ * ```js
561
+ * import util from 'node:util';
562
+ *
563
+ * util.isDate(new Date());
564
+ * // Returns: true
565
+ * util.isDate(Date());
566
+ * // false (without 'new' returns a String)
567
+ * util.isDate({});
568
+ * // Returns: false
569
+ * ```
570
+ * @since v0.6.0
571
+ * @deprecated Since v4.0.0 - Use {@link types.isDate} instead.
572
+ */
573
+ export function isDate(object: unknown): object is Date;
574
+ /**
575
+ * Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
576
+ *
577
+ * ```js
578
+ * import util from 'node:util';
579
+ *
580
+ * util.isError(new Error());
581
+ * // Returns: true
582
+ * util.isError(new TypeError());
583
+ * // Returns: true
584
+ * util.isError({ name: 'Error', message: 'an error occurred' });
585
+ * // Returns: false
586
+ * ```
587
+ *
588
+ * This method relies on `Object.prototype.toString()` behavior. It is
589
+ * possible to obtain an incorrect result when the `object` argument manipulates `@@toStringTag`.
590
+ *
591
+ * ```js
592
+ * import util from 'node:util';
593
+ * const obj = { name: 'Error', message: 'an error occurred' };
594
+ *
595
+ * util.isError(obj);
596
+ * // Returns: false
597
+ * obj[Symbol.toStringTag] = 'Error';
598
+ * util.isError(obj);
599
+ * // Returns: true
600
+ * ```
601
+ * @since v0.6.0
602
+ * @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead.
603
+ */
604
+ export function isError(object: unknown): object is Error;
605
+ /**
606
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and `extends` keywords to get language level inheritance support. Also note
607
+ * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
608
+ *
609
+ * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
610
+ * prototype of `constructor` will be set to a new object created from `superConstructor`.
611
+ *
612
+ * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
613
+ * As an additional convenience, `superConstructor` will be accessible
614
+ * through the `constructor.super_` property.
615
+ *
616
+ * ```js
617
+ * import util from 'node:util';
618
+ * import EventEmitter from 'node:events';
619
+ *
620
+ * function MyStream() {
621
+ * EventEmitter.call(this);
622
+ * }
623
+ *
624
+ * util.inherits(MyStream, EventEmitter);
625
+ *
626
+ * MyStream.prototype.write = function(data) {
627
+ * this.emit('data', data);
628
+ * };
629
+ *
630
+ * const stream = new MyStream();
631
+ *
632
+ * console.log(stream instanceof EventEmitter); // true
633
+ * console.log(MyStream.super_ === EventEmitter); // true
634
+ *
635
+ * stream.on('data', (data) => {
636
+ * console.log(`Received data: "${data}"`);
637
+ * });
638
+ * stream.write('It works!'); // Received data: "It works!"
639
+ * ```
640
+ *
641
+ * ES6 example using `class` and `extends`:
642
+ *
643
+ * ```js
644
+ * import EventEmitter from 'node:events';
645
+ *
646
+ * class MyStream extends EventEmitter {
647
+ * write(data) {
648
+ * this.emit('data', data);
649
+ * }
650
+ * }
651
+ *
652
+ * const stream = new MyStream();
653
+ *
654
+ * stream.on('data', (data) => {
655
+ * console.log(`Received data: "${data}"`);
656
+ * });
657
+ * stream.write('With ES6');
658
+ * ```
659
+ * @since v0.3.0
660
+ * @legacy Use ES2015 class syntax and `extends` keyword instead.
661
+ */
662
+ export function inherits(constructor: unknown, superConstructor: unknown): void;
663
+ export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
664
+ export interface DebugLogger extends DebugLoggerFunction {
665
+ enabled: boolean;
666
+ }
667
+ /**
668
+ * The `util.debuglog()` method is used to create a function that conditionally
669
+ * 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
670
+ * environment variable, then the returned function operates similar to `console.error()`. If not, then the returned function is a no-op.
671
+ *
672
+ * ```js
673
+ * import util from 'node:util';
674
+ * const debuglog = util.debuglog('foo');
675
+ *
676
+ * debuglog('hello from foo [%d]', 123);
677
+ * ```
678
+ *
679
+ * If this program is run with `NODE_DEBUG=foo` in the environment, then
680
+ * it will output something like:
681
+ *
682
+ * ```console
683
+ * FOO 3245: hello from foo [123]
684
+ * ```
685
+ *
686
+ * where `3245` is the process id. If it is not run with that
687
+ * environment variable set, then it will not print anything.
688
+ *
689
+ * The `section` supports wildcard also:
690
+ *
691
+ * ```js
692
+ * import util from 'node:util';
693
+ * const debuglog = util.debuglog('foo-bar');
694
+ *
695
+ * debuglog('hi there, it\'s foo-bar [%d]', 2333);
696
+ * ```
697
+ *
698
+ * if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
699
+ * something like:
700
+ *
701
+ * ```console
702
+ * FOO-BAR 3257: hi there, it's foo-bar [2333]
703
+ * ```
704
+ *
705
+ * Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`environment variable: `NODE_DEBUG=fs,net,tls`.
706
+ *
707
+ * The optional `callback` argument can be used to replace the logging function
708
+ * with a different function that doesn't have any initialization or
709
+ * unnecessary wrapping.
710
+ *
711
+ * ```js
712
+ * import util from 'node:util';
713
+ * let debuglog = util.debuglog('internals', (debug) => {
714
+ * // Replace with a logging function that optimizes out
715
+ * // testing if the section is enabled
716
+ * debuglog = debug;
717
+ * });
718
+ * ```
719
+ * @since v0.11.3
720
+ * @param section A string identifying the portion of the application for which the `debuglog` function is being created.
721
+ * @param callback A callback invoked the first time the logging function is called with a function argument that is a more optimized logging function.
722
+ * @return The logging function
723
+ */
724
+ export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
725
+ export const debug: typeof debuglog;
726
+ /**
727
+ * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
728
+ *
729
+ * ```js
730
+ * import util from 'node:util';
731
+ *
732
+ * util.isBoolean(1);
733
+ * // Returns: false
734
+ * util.isBoolean(0);
735
+ * // Returns: false
736
+ * util.isBoolean(false);
737
+ * // Returns: true
738
+ * ```
739
+ * @since v0.11.5
740
+ * @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead.
741
+ */
742
+ export function isBoolean(object: unknown): object is boolean;
743
+ /**
744
+ * Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
745
+ *
746
+ * ```js
747
+ * import util from 'node:util';
748
+ *
749
+ * util.isBuffer({ length: 0 });
750
+ * // Returns: false
751
+ * util.isBuffer([]);
752
+ * // Returns: false
753
+ * util.isBuffer(Buffer.from('hello world'));
754
+ * // Returns: true
755
+ * ```
756
+ * @since v0.11.5
757
+ * @deprecated Since v4.0.0 - Use `isBuffer` instead.
758
+ */
759
+ export function isBuffer(object: unknown): object is Buffer;
760
+ /**
761
+ * Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`.
762
+ *
763
+ * ```js
764
+ * import util from 'node:util';
765
+ *
766
+ * function Foo() {}
767
+ * const Bar = () => {};
768
+ *
769
+ * util.isFunction({});
770
+ * // Returns: false
771
+ * util.isFunction(Foo);
772
+ * // Returns: true
773
+ * util.isFunction(Bar);
774
+ * // Returns: true
775
+ * ```
776
+ * @since v0.11.5
777
+ * @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead.
778
+ */
779
+ export function isFunction(object: unknown): boolean;
780
+ /**
781
+ * Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
782
+ *
783
+ * ```js
784
+ * import util from 'node:util';
785
+ *
786
+ * util.isNull(0);
787
+ * // Returns: false
788
+ * util.isNull(undefined);
789
+ * // Returns: false
790
+ * util.isNull(null);
791
+ * // Returns: true
792
+ * ```
793
+ * @since v0.11.5
794
+ * @deprecated Since v4.0.0 - Use `value === null` instead.
795
+ */
796
+ export function isNull(object: unknown): object is null;
797
+ /**
798
+ * Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
799
+ * returns `false`.
800
+ *
801
+ * ```js
802
+ * import util from 'node:util';
803
+ *
804
+ * util.isNullOrUndefined(0);
805
+ * // Returns: false
806
+ * util.isNullOrUndefined(undefined);
807
+ * // Returns: true
808
+ * util.isNullOrUndefined(null);
809
+ * // Returns: true
810
+ * ```
811
+ * @since v0.11.5
812
+ * @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
813
+ */
814
+ export function isNullOrUndefined(object: unknown): object is null | undefined;
815
+ /**
816
+ * Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
817
+ *
818
+ * ```js
819
+ * import util from 'node:util';
820
+ *
821
+ * util.isNumber(false);
822
+ * // Returns: false
823
+ * util.isNumber(Infinity);
824
+ * // Returns: true
825
+ * util.isNumber(0);
826
+ * // Returns: true
827
+ * util.isNumber(NaN);
828
+ * // Returns: true
829
+ * ```
830
+ * @since v0.11.5
831
+ * @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead.
832
+ */
833
+ export function isNumber(object: unknown): object is number;
834
+ /**
835
+ * Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript).
836
+ * Otherwise, returns `false`.
837
+ *
838
+ * ```js
839
+ * import util from 'node:util';
840
+ *
841
+ * util.isObject(5);
842
+ * // Returns: false
843
+ * util.isObject(null);
844
+ * // Returns: false
845
+ * util.isObject({});
846
+ * // Returns: true
847
+ * util.isObject(() => {});
848
+ * // Returns: false
849
+ * ```
850
+ * @since v0.11.5
851
+ * @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead.
852
+ */
853
+ export function isObject(object: unknown): boolean;
854
+ /**
855
+ * Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
856
+ *
857
+ * ```js
858
+ * import util from 'node:util';
859
+ *
860
+ * util.isPrimitive(5);
861
+ * // Returns: true
862
+ * util.isPrimitive('foo');
863
+ * // Returns: true
864
+ * util.isPrimitive(false);
865
+ * // Returns: true
866
+ * util.isPrimitive(null);
867
+ * // Returns: true
868
+ * util.isPrimitive(undefined);
869
+ * // Returns: true
870
+ * util.isPrimitive({});
871
+ * // Returns: false
872
+ * util.isPrimitive(() => {});
873
+ * // Returns: false
874
+ * util.isPrimitive(/^$/);
875
+ * // Returns: false
876
+ * util.isPrimitive(new Date());
877
+ * // Returns: false
878
+ * ```
879
+ * @since v0.11.5
880
+ * @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead.
881
+ */
882
+ export function isPrimitive(object: unknown): boolean;
883
+ /**
884
+ * Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
885
+ *
886
+ * ```js
887
+ * import util from 'node:util';
888
+ *
889
+ * util.isString('');
890
+ * // Returns: true
891
+ * util.isString('foo');
892
+ * // Returns: true
893
+ * util.isString(String('foo'));
894
+ * // Returns: true
895
+ * util.isString(5);
896
+ * // Returns: false
897
+ * ```
898
+ * @since v0.11.5
899
+ * @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead.
900
+ */
901
+ export function isString(object: unknown): object is string;
902
+ /**
903
+ * Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
904
+ *
905
+ * ```js
906
+ * import util from 'node:util';
907
+ *
908
+ * util.isSymbol(5);
909
+ * // Returns: false
910
+ * util.isSymbol('foo');
911
+ * // Returns: false
912
+ * util.isSymbol(Symbol('foo'));
913
+ * // Returns: true
914
+ * ```
915
+ * @since v0.11.5
916
+ * @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead.
917
+ */
918
+ export function isSymbol(object: unknown): object is symbol;
919
+ /**
920
+ * Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
921
+ *
922
+ * ```js
923
+ * import util from 'node:util';
924
+ *
925
+ * const foo = undefined;
926
+ * util.isUndefined(5);
927
+ * // Returns: false
928
+ * util.isUndefined(foo);
929
+ * // Returns: true
930
+ * util.isUndefined(null);
931
+ * // Returns: false
932
+ * ```
933
+ * @since v0.11.5
934
+ * @deprecated Since v4.0.0 - Use `value === undefined` instead.
935
+ */
936
+ export function isUndefined(object: unknown): object is undefined;
937
+ /**
938
+ * The `util.deprecate()` method wraps `fn` (which may be a function or class) in
939
+ * such a way that it is marked as deprecated.
940
+ *
941
+ * ```js
942
+ * import util from 'node:util';
943
+ *
944
+ * exports.obsoleteFunction = util.deprecate(() => {
945
+ * // Do something here.
946
+ * }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
947
+ * ```
948
+ *
949
+ * When called, `util.deprecate()` will return a function that will emit a `DeprecationWarning` using the `'warning'` event. The warning will
950
+ * be emitted and printed to `stderr` the first time the returned function is
951
+ * called. After the warning is emitted, the wrapped function is called without
952
+ * emitting a warning.
953
+ *
954
+ * If the same optional `code` is supplied in multiple calls to `util.deprecate()`,
955
+ * the warning will be emitted only once for that `code`.
956
+ *
957
+ * ```js
958
+ * import util from 'node:util';
959
+ *
960
+ * const fn1 = util.deprecate(someFunction, someMessage, 'DEP0001');
961
+ * const fn2 = util.deprecate(someOtherFunction, someOtherMessage, 'DEP0001');
962
+ * fn1(); // Emits a deprecation warning with code DEP0001
963
+ * fn2(); // Does not emit a deprecation warning because it has the same code
964
+ * ```
965
+ *
966
+ * If either the `--no-deprecation` or `--no-warnings` command-line flags are
967
+ * used, or if the `process.noDeprecation` property is set to `true`_prior_ to
968
+ * the first deprecation warning, the `util.deprecate()` method does nothing.
969
+ *
970
+ * If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
971
+ * or the `process.traceDeprecation` property is set to `true`, a warning and a
972
+ * stack trace are printed to `stderr` the first time the deprecated function is
973
+ * called.
974
+ *
975
+ * If the `--throw-deprecation` command-line flag is set, or the `process.throwDeprecation` property is set to `true`, then an exception will be
976
+ * thrown when the deprecated function is called.
977
+ *
978
+ * The `--throw-deprecation` command-line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation` and `process.traceDeprecation`.
979
+ * @since v0.8.0
980
+ * @param fn The function that is being deprecated.
981
+ * @param msg A warning message to display when the deprecated function is invoked.
982
+ * @param code A deprecation code. See the `list of deprecated APIs` for a list of codes.
983
+ * @return The deprecated function wrapped to emit a warning.
984
+ */
985
+ export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
986
+ /**
987
+ * Returns `true` if there is deep strict equality between `val1` and `val2`.
988
+ * Otherwise, returns `false`.
989
+ *
990
+ * See `assert.deepStrictEqual()` for more information about deep strict
991
+ * equality.
992
+ * @since v9.0.0
993
+ */
994
+ export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
995
+ /**
996
+ * Returns `str` with any ANSI escape codes removed.
997
+ *
998
+ * ```js
999
+ * console.log(util.stripVTControlCharacters('\u001B[4mvalue\u001B[0m'));
1000
+ * // Prints "value"
1001
+ * ```
1002
+ * @since v16.11.0
1003
+ */
1004
+ export function stripVTControlCharacters(str: string): string;
1005
+ /**
1006
+ * Takes an `async` function (or a function that returns a `Promise`) and returns a
1007
+ * function following the error-first callback style, i.e. taking
1008
+ * an `(err, value) => ...` callback as the last argument. In the callback, the
1009
+ * first argument will be the rejection reason (or `null` if the `Promise` resolved), and the second argument will be the resolved value.
1010
+ *
1011
+ * ```js
1012
+ * import util from 'node:util';
1013
+ *
1014
+ * async function fn() {
1015
+ * return 'hello world';
1016
+ * }
1017
+ * const callbackFunction = util.callbackify(fn);
1018
+ *
1019
+ * callbackFunction((err, ret) => {
1020
+ * if (err) throw err;
1021
+ * console.log(ret);
1022
+ * });
1023
+ * ```
1024
+ *
1025
+ * Will print:
1026
+ *
1027
+ * ```text
1028
+ * hello world
1029
+ * ```
1030
+ *
1031
+ * The callback is executed asynchronously, and will have a limited stack trace.
1032
+ * If the callback throws, the process will emit an `'uncaughtException'` event, and if not handled will exit.
1033
+ *
1034
+ * Since `null` has a special meaning as the first argument to a callback, if a
1035
+ * wrapped function rejects a `Promise` with a falsy value as a reason, the value
1036
+ * is wrapped in an `Error` with the original value stored in a field named `reason`.
1037
+ *
1038
+ * ```js
1039
+ * function fn() {
1040
+ * return Promise.reject(null);
1041
+ * }
1042
+ * const callbackFunction = util.callbackify(fn);
1043
+ *
1044
+ * callbackFunction((err, ret) => {
1045
+ * // When the Promise was rejected with `null` it is wrapped with an Error and
1046
+ * // the original value is stored in `reason`.
1047
+ * err &#x26;&#x26; Object.hasOwn(err, 'reason') &#x26;&#x26; err.reason === null; // true
1048
+ * });
1049
+ * ```
1050
+ * @since v8.2.0
1051
+ * @param fn An `async` function
1052
+ * @return a callback style function
1053
+ */
1054
+ export function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
1055
+ export function callbackify<TResult>(
1056
+ fn: () => Promise<TResult>,
1057
+ ): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
1058
+ export function callbackify<T1>(
1059
+ fn: (arg1: T1) => Promise<void>,
1060
+ ): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
1061
+ export function callbackify<T1, TResult>(
1062
+ fn: (arg1: T1) => Promise<TResult>,
1063
+ ): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
1064
+ export function callbackify<T1, T2>(
1065
+ fn: (arg1: T1, arg2: T2) => Promise<void>,
1066
+ ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
1067
+ export function callbackify<T1, T2, TResult>(
1068
+ fn: (arg1: T1, arg2: T2) => Promise<TResult>,
1069
+ ): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
1070
+ export function callbackify<T1, T2, T3>(
1071
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>,
1072
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
1073
+ export function callbackify<T1, T2, T3, TResult>(
1074
+ fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>,
1075
+ ): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
1076
+ export function callbackify<T1, T2, T3, T4>(
1077
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>,
1078
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
1079
+ export function callbackify<T1, T2, T3, T4, TResult>(
1080
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>,
1081
+ ): (
1082
+ arg1: T1,
1083
+ arg2: T2,
1084
+ arg3: T3,
1085
+ arg4: T4,
1086
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
1087
+ ) => void;
1088
+ export function callbackify<T1, T2, T3, T4, T5>(
1089
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>,
1090
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
1091
+ export function callbackify<T1, T2, T3, T4, T5, TResult>(
1092
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
1093
+ ): (
1094
+ arg1: T1,
1095
+ arg2: T2,
1096
+ arg3: T3,
1097
+ arg4: T4,
1098
+ arg5: T5,
1099
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
1100
+ ) => void;
1101
+ export function callbackify<T1, T2, T3, T4, T5, T6>(
1102
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
1103
+ ): (
1104
+ arg1: T1,
1105
+ arg2: T2,
1106
+ arg3: T3,
1107
+ arg4: T4,
1108
+ arg5: T5,
1109
+ arg6: T6,
1110
+ callback: (err: NodeJS.ErrnoException) => void,
1111
+ ) => void;
1112
+ export function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
1113
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>,
1114
+ ): (
1115
+ arg1: T1,
1116
+ arg2: T2,
1117
+ arg3: T3,
1118
+ arg4: T4,
1119
+ arg5: T5,
1120
+ arg6: T6,
1121
+ callback: (err: NodeJS.ErrnoException | null, result: TResult) => void,
1122
+ ) => void;
1123
+ export interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
1124
+ __promisify__: TCustom;
1125
+ }
1126
+ export interface CustomPromisifySymbol<TCustom extends Function> extends Function {
1127
+ [promisify.custom]: TCustom;
1128
+ }
1129
+ export type CustomPromisify<TCustom extends Function> =
1130
+ | CustomPromisifySymbol<TCustom>
1131
+ | CustomPromisifyLegacy<TCustom>;
1132
+ /**
1133
+ * Takes a function following the common error-first callback style, i.e. taking
1134
+ * an `(err, value) => ...` callback as the last argument, and returns a version
1135
+ * that returns promises.
1136
+ *
1137
+ * ```js
1138
+ * import util from 'node:util';
1139
+ * import fs from 'node:fs';
1140
+ *
1141
+ * const stat = util.promisify(fs.stat);
1142
+ * stat('.').then((stats) => {
1143
+ * // Do something with `stats`
1144
+ * }).catch((error) => {
1145
+ * // Handle the error.
1146
+ * });
1147
+ * ```
1148
+ *
1149
+ * Or, equivalently using `async function`s:
1150
+ *
1151
+ * ```js
1152
+ * import util from 'node:util';
1153
+ * import fs from 'node:fs';
1154
+ *
1155
+ * const stat = util.promisify(fs.stat);
1156
+ *
1157
+ * async function callStat() {
1158
+ * const stats = await stat('.');
1159
+ * console.log(`This directory is owned by ${stats.uid}`);
1160
+ * }
1161
+ *
1162
+ * callStat();
1163
+ * ```
1164
+ *
1165
+ * If there is an `original[util.promisify.custom]` property present, `promisify` will return its value, see `Custom promisified functions`.
1166
+ *
1167
+ * `promisify()` assumes that `original` is a function taking a callback as its
1168
+ * 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
1169
+ * an error-first callback, it will still be passed an error-first
1170
+ * callback as its last argument.
1171
+ *
1172
+ * Using `promisify()` on class methods or other methods that use `this` may not
1173
+ * work as expected unless handled specially:
1174
+ *
1175
+ * ```js
1176
+ * import util from 'node:util';
1177
+ *
1178
+ * class Foo {
1179
+ * constructor() {
1180
+ * this.a = 42;
1181
+ * }
1182
+ *
1183
+ * bar(callback) {
1184
+ * callback(null, this.a);
1185
+ * }
1186
+ * }
1187
+ *
1188
+ * const foo = new Foo();
1189
+ *
1190
+ * const naiveBar = util.promisify(foo.bar);
1191
+ * // TypeError: Cannot read property 'a' of undefined
1192
+ * // naiveBar().then(a => console.log(a));
1193
+ *
1194
+ * naiveBar.call(foo).then((a) => console.log(a)); // '42'
1195
+ *
1196
+ * const bindBar = naiveBar.bind(foo);
1197
+ * bindBar().then((a) => console.log(a)); // '42'
1198
+ * ```
1199
+ * @since v8.0.0
1200
+ */
1201
+ export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
1202
+ export function promisify<TResult>(
1203
+ fn: (callback: (err: any, result: TResult) => void) => void,
1204
+ ): () => Promise<TResult>;
1205
+ export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
1206
+ export function promisify<T1, TResult>(
1207
+ fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void,
1208
+ ): (arg1: T1) => Promise<TResult>;
1209
+ export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
1210
+ export function promisify<T1, T2, TResult>(
1211
+ fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void,
1212
+ ): (arg1: T1, arg2: T2) => Promise<TResult>;
1213
+ export function promisify<T1, T2>(
1214
+ fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void,
1215
+ ): (arg1: T1, arg2: T2) => Promise<void>;
1216
+ export function promisify<T1, T2, T3, TResult>(
1217
+ fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void,
1218
+ ): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
1219
+ export function promisify<T1, T2, T3>(
1220
+ fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void,
1221
+ ): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
1222
+ export function promisify<T1, T2, T3, T4, TResult>(
1223
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
1224
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
1225
+ export function promisify<T1, T2, T3, T4>(
1226
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void,
1227
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
1228
+ export function promisify<T1, T2, T3, T4, T5, TResult>(
1229
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
1230
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
1231
+ export function promisify<T1, T2, T3, T4, T5>(
1232
+ fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
1233
+ ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
1234
+ export function promisify(fn: Function): Function;
1235
+ export namespace promisify {
1236
+ /**
1237
+ * That can be used to declare custom promisified variants of functions.
1238
+ */
1239
+ const custom: unique symbol;
1240
+ }
1241
+ /**
1242
+ * Stability: 1.1 - Active development
1243
+ * Given an example `.env` file:
1244
+ *
1245
+ * ```js
1246
+ * import { parseEnv } from 'node:util';
1247
+ *
1248
+ * parseEnv('HELLO=world\nHELLO=oh my\n');
1249
+ * // Returns: { HELLO: 'oh my' }
1250
+ * ```
1251
+ * @param content The raw contents of a `.env` file.
1252
+ * @since v20.12.0
1253
+ */
1254
+ export function parseEnv(content: string): object;
1255
+ // https://nodejs.org/docs/latest/api/util.html#foreground-colors
1256
+ type ForegroundColors =
1257
+ | "black"
1258
+ | "blackBright"
1259
+ | "blue"
1260
+ | "blueBright"
1261
+ | "cyan"
1262
+ | "cyanBright"
1263
+ | "gray"
1264
+ | "green"
1265
+ | "greenBright"
1266
+ | "grey"
1267
+ | "magenta"
1268
+ | "magentaBright"
1269
+ | "red"
1270
+ | "redBright"
1271
+ | "white"
1272
+ | "whiteBright"
1273
+ | "yellow"
1274
+ | "yellowBright";
1275
+ // https://nodejs.org/docs/latest/api/util.html#background-colors
1276
+ type BackgroundColors =
1277
+ | "bgBlack"
1278
+ | "bgBlackBright"
1279
+ | "bgBlue"
1280
+ | "bgBlueBright"
1281
+ | "bgCyan"
1282
+ | "bgCyanBright"
1283
+ | "bgGray"
1284
+ | "bgGreen"
1285
+ | "bgGreenBright"
1286
+ | "bgGrey"
1287
+ | "bgMagenta"
1288
+ | "bgMagentaBright"
1289
+ | "bgRed"
1290
+ | "bgRedBright"
1291
+ | "bgWhite"
1292
+ | "bgWhiteBright"
1293
+ | "bgYellow"
1294
+ | "bgYellowBright";
1295
+ // https://nodejs.org/docs/latest/api/util.html#modifiers
1296
+ type Modifiers =
1297
+ | "blink"
1298
+ | "bold"
1299
+ | "dim"
1300
+ | "doubleunderline"
1301
+ | "framed"
1302
+ | "hidden"
1303
+ | "inverse"
1304
+ | "italic"
1305
+ | "overlined"
1306
+ | "reset"
1307
+ | "strikethrough"
1308
+ | "underline";
1309
+ /**
1310
+ * Stability: 1.1 - Active development
1311
+ *
1312
+ * This function returns a formatted text considering the `format` passed.
1313
+ *
1314
+ * ```js
1315
+ * import { styleText } from 'node:util';
1316
+ * const errorMessage = styleText('red', 'Error! Error!');
1317
+ * console.log(errorMessage);
1318
+ * ```
1319
+ *
1320
+ * `util.inspect.colors` also provides text formats such as `italic`, and `underline` and you can combine both:
1321
+ *
1322
+ * ```js
1323
+ * console.log(
1324
+ * util.styleText(['underline', 'italic'], 'My italic underlined message'),
1325
+ * );
1326
+ * ```
1327
+ *
1328
+ * When passing an array of formats, the order of the format applied is left to right so the following style
1329
+ * might overwrite the previous one.
1330
+ *
1331
+ * ```js
1332
+ * console.log(
1333
+ * util.styleText(['red', 'green'], 'text'), // green
1334
+ * );
1335
+ * ```
1336
+ *
1337
+ * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v22.x/api/util.html#modifiers).
1338
+ * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1339
+ * @param text The text to to be formatted.
1340
+ * @since v20.12.0
1341
+ */
1342
+ export function styleText(
1343
+ format:
1344
+ | ForegroundColors
1345
+ | BackgroundColors
1346
+ | Modifiers
1347
+ | Array<ForegroundColors | BackgroundColors | Modifiers>,
1348
+ text: string,
1349
+ ): string;
1350
+ /**
1351
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
1352
+ *
1353
+ * ```js
1354
+ * const decoder = new TextDecoder();
1355
+ * const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
1356
+ * console.log(decoder.decode(u8arr)); // Hello
1357
+ * ```
1358
+ * @since v8.3.0
1359
+ */
1360
+ export class TextDecoder {
1361
+ /**
1362
+ * The encoding supported by the `TextDecoder` instance.
1363
+ */
1364
+ readonly encoding: string;
1365
+ /**
1366
+ * The value will be `true` if decoding errors result in a `TypeError` being
1367
+ * thrown.
1368
+ */
1369
+ readonly fatal: boolean;
1370
+ /**
1371
+ * The value will be `true` if the decoding result will include the byte order
1372
+ * mark.
1373
+ */
1374
+ readonly ignoreBOM: boolean;
1375
+ constructor(
1376
+ encoding?: string,
1377
+ options?: {
1378
+ fatal?: boolean | undefined;
1379
+ ignoreBOM?: boolean | undefined;
1380
+ },
1381
+ );
1382
+ /**
1383
+ * Decodes the `input` and returns a string. If `options.stream` is `true`, any
1384
+ * incomplete byte sequences occurring at the end of the `input` are buffered
1385
+ * internally and emitted after the next call to `textDecoder.decode()`.
1386
+ *
1387
+ * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a `TypeError` being thrown.
1388
+ * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data.
1389
+ */
1390
+ decode(
1391
+ input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
1392
+ options?: {
1393
+ stream?: boolean | undefined;
1394
+ },
1395
+ ): string;
1396
+ }
1397
+ export interface EncodeIntoResult {
1398
+ /**
1399
+ * The read Unicode code units of input.
1400
+ */
1401
+ read: number;
1402
+ /**
1403
+ * The written UTF-8 bytes of output.
1404
+ */
1405
+ written: number;
1406
+ }
1407
+ export { types };
1408
+
1409
+ //// TextEncoder/Decoder
1410
+ /**
1411
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
1412
+ * instances of `TextEncoder` only support UTF-8 encoding.
1413
+ *
1414
+ * ```js
1415
+ * const encoder = new TextEncoder();
1416
+ * const uint8array = encoder.encode('this is some data');
1417
+ * ```
1418
+ *
1419
+ * The `TextEncoder` class is also available on the global object.
1420
+ * @since v8.3.0
1421
+ */
1422
+ export class TextEncoder {
1423
+ /**
1424
+ * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
1425
+ */
1426
+ readonly encoding: string;
1427
+ /**
1428
+ * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
1429
+ * encoded bytes.
1430
+ * @param [input='an empty string'] The text to encode.
1431
+ */
1432
+ encode(input?: string): Uint8Array;
1433
+ /**
1434
+ * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
1435
+ * containing the read Unicode code units and written UTF-8 bytes.
1436
+ *
1437
+ * ```js
1438
+ * const encoder = new TextEncoder();
1439
+ * const src = 'this is some data';
1440
+ * const dest = new Uint8Array(10);
1441
+ * const { read, written } = encoder.encodeInto(src, dest);
1442
+ * ```
1443
+ * @param src The text to encode.
1444
+ * @param dest The array to hold the encode result.
1445
+ */
1446
+ encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
1447
+ }
1448
+ import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from "util";
1449
+ global {
1450
+ /**
1451
+ * `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
1452
+ * https://nodejs.org/api/globals.html#textdecoder
1453
+ * @since v11.0.0
1454
+ */
1455
+ var TextDecoder: typeof globalThis extends {
1456
+ onmessage: any;
1457
+ TextDecoder: infer TextDecoder;
1458
+ } ? TextDecoder
1459
+ : typeof _TextDecoder;
1460
+ /**
1461
+ * `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
1462
+ * https://nodejs.org/api/globals.html#textencoder
1463
+ * @since v11.0.0
1464
+ */
1465
+ var TextEncoder: typeof globalThis extends {
1466
+ onmessage: any;
1467
+ TextEncoder: infer TextEncoder;
1468
+ } ? TextEncoder
1469
+ : typeof _TextEncoder;
1470
+ }
1471
+
1472
+ //// parseArgs
1473
+ /**
1474
+ * Provides a higher level API for command-line argument parsing than interacting
1475
+ * with `process.argv` directly. Takes a specification for the expected arguments
1476
+ * and returns a structured object with the parsed options and positionals.
1477
+ *
1478
+ * ```js
1479
+ * import { parseArgs } from 'node:util';
1480
+ * const args = ['-f', '--bar', 'b'];
1481
+ * const options = {
1482
+ * foo: {
1483
+ * type: 'boolean',
1484
+ * short: 'f',
1485
+ * },
1486
+ * bar: {
1487
+ * type: 'string',
1488
+ * },
1489
+ * };
1490
+ * const {
1491
+ * values,
1492
+ * positionals,
1493
+ * } = parseArgs({ args, options });
1494
+ * console.log(values, positionals);
1495
+ * // Prints: [Object: null prototype] { foo: true, bar: 'b' } []
1496
+ * ```
1497
+ * @since v18.3.0, v16.17.0
1498
+ * @param config Used to provide arguments for parsing and to configure the parser. `config` supports the following properties:
1499
+ * @return The parsed command line arguments:
1500
+ */
1501
+ export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
1502
+ interface ParseArgsOptionConfig {
1503
+ /**
1504
+ * Type of argument.
1505
+ */
1506
+ type: "string" | "boolean";
1507
+ /**
1508
+ * Whether this option can be provided multiple times.
1509
+ * If `true`, all values will be collected in an array.
1510
+ * If `false`, values for the option are last-wins.
1511
+ * @default false.
1512
+ */
1513
+ multiple?: boolean | undefined;
1514
+ /**
1515
+ * A single character alias for the option.
1516
+ */
1517
+ short?: string | undefined;
1518
+ /**
1519
+ * The default option value when it is not set by args.
1520
+ * It must be of the same type as the the `type` property.
1521
+ * When `multiple` is `true`, it must be an array.
1522
+ * @since v18.11.0
1523
+ */
1524
+ default?: string | boolean | string[] | boolean[] | undefined;
1525
+ }
1526
+ interface ParseArgsOptionsConfig {
1527
+ [longOption: string]: ParseArgsOptionConfig;
1528
+ }
1529
+ export interface ParseArgsConfig {
1530
+ /**
1531
+ * Array of argument strings.
1532
+ */
1533
+ args?: string[] | undefined;
1534
+ /**
1535
+ * Used to describe arguments known to the parser.
1536
+ */
1537
+ options?: ParseArgsOptionsConfig | undefined;
1538
+ /**
1539
+ * Should an error be thrown when unknown arguments are encountered,
1540
+ * or when arguments are passed that do not match the `type` configured in `options`.
1541
+ * @default true
1542
+ */
1543
+ strict?: boolean | undefined;
1544
+ /**
1545
+ * Whether this command accepts positional arguments.
1546
+ */
1547
+ allowPositionals?: boolean | undefined;
1548
+ /**
1549
+ * If `true`, allows explicitly setting boolean options to `false` by prefixing the option name with `--no-`.
1550
+ * @default false
1551
+ * @since v22.4.0
1552
+ */
1553
+ allowNegative?: boolean | undefined;
1554
+ /**
1555
+ * Return the parsed tokens. This is useful for extending the built-in behavior,
1556
+ * from adding additional checks through to reprocessing the tokens in different ways.
1557
+ * @default false
1558
+ */
1559
+ tokens?: boolean | undefined;
1560
+ }
1561
+ /*
1562
+ IfDefaultsTrue and IfDefaultsFalse are helpers to handle default values for missing boolean properties.
1563
+ TypeScript does not have exact types for objects: https://github.com/microsoft/TypeScript/issues/12936
1564
+ This means it is impossible to distinguish between "field X is definitely not present" and "field X may or may not be present".
1565
+ 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.
1566
+ 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.
1567
+ This is technically incorrect but is a much nicer UX for the common case.
1568
+ The IfDefaultsTrue version is for things which default to true; the IfDefaultsFalse version is for things which default to false.
1569
+ */
1570
+ type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true ? IfTrue
1571
+ : T extends false ? IfFalse
1572
+ : IfTrue;
1573
+
1574
+ // we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
1575
+ type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false ? IfFalse
1576
+ : T extends true ? IfTrue
1577
+ : IfFalse;
1578
+
1579
+ type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionConfig> = IfDefaultsTrue<
1580
+ T["strict"],
1581
+ O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
1582
+ string | boolean
1583
+ >;
1584
+
1585
+ type ApplyOptionalModifiers<O extends ParseArgsOptionsConfig, V extends Record<keyof O, unknown>> = (
1586
+ & { -readonly [LongOption in keyof O]?: V[LongOption] }
1587
+ & { [LongOption in keyof O as O[LongOption]["default"] extends {} ? LongOption : never]: V[LongOption] }
1588
+ ) extends infer P ? { [K in keyof P]: P[K] } : never; // resolve intersection to object
1589
+
1590
+ type ParsedValues<T extends ParseArgsConfig> =
1591
+ & IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
1592
+ & (T["options"] extends ParseArgsOptionsConfig ? ApplyOptionalModifiers<
1593
+ T["options"],
1594
+ {
1595
+ [LongOption in keyof T["options"]]: IfDefaultsFalse<
1596
+ T["options"][LongOption]["multiple"],
1597
+ Array<ExtractOptionValue<T, T["options"][LongOption]>>,
1598
+ ExtractOptionValue<T, T["options"][LongOption]>
1599
+ >;
1600
+ }
1601
+ >
1602
+ : {});
1603
+
1604
+ type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
1605
+ T["strict"],
1606
+ IfDefaultsFalse<T["allowPositionals"], string[], []>,
1607
+ IfDefaultsTrue<T["allowPositionals"], string[], []>
1608
+ >;
1609
+
1610
+ type PreciseTokenForOptions<
1611
+ K extends string,
1612
+ O extends ParseArgsOptionConfig,
1613
+ > = O["type"] extends "string" ? {
1614
+ kind: "option";
1615
+ index: number;
1616
+ name: K;
1617
+ rawName: string;
1618
+ value: string;
1619
+ inlineValue: boolean;
1620
+ }
1621
+ : O["type"] extends "boolean" ? {
1622
+ kind: "option";
1623
+ index: number;
1624
+ name: K;
1625
+ rawName: string;
1626
+ value: undefined;
1627
+ inlineValue: undefined;
1628
+ }
1629
+ : OptionToken & { name: K };
1630
+
1631
+ type TokenForOptions<
1632
+ T extends ParseArgsConfig,
1633
+ K extends keyof T["options"] = keyof T["options"],
1634
+ > = K extends unknown
1635
+ ? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions<K & string, T["options"][K]>
1636
+ : OptionToken
1637
+ : never;
1638
+
1639
+ type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T["strict"], TokenForOptions<T>, OptionToken>;
1640
+
1641
+ type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
1642
+ T["strict"],
1643
+ IfDefaultsFalse<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>,
1644
+ IfDefaultsTrue<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>
1645
+ >;
1646
+
1647
+ type ParsedTokens<T extends ParseArgsConfig> = Array<
1648
+ ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: "option-terminator"; index: number }
1649
+ >;
1650
+
1651
+ type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
1652
+ T["tokens"],
1653
+ {
1654
+ values: ParsedValues<T>;
1655
+ positionals: ParsedPositionals<T>;
1656
+ tokens: ParsedTokens<T>;
1657
+ },
1658
+ {
1659
+ values: ParsedValues<T>;
1660
+ positionals: ParsedPositionals<T>;
1661
+ }
1662
+ >;
1663
+
1664
+ type OptionToken =
1665
+ | { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
1666
+ | {
1667
+ kind: "option";
1668
+ index: number;
1669
+ name: string;
1670
+ rawName: string;
1671
+ value: undefined;
1672
+ inlineValue: undefined;
1673
+ };
1674
+
1675
+ type Token =
1676
+ | OptionToken
1677
+ | { kind: "positional"; index: number; value: string }
1678
+ | { kind: "option-terminator"; index: number };
1679
+
1680
+ // If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
1681
+ // So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
1682
+ type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T ? {
1683
+ values: {
1684
+ [longOption: string]: undefined | string | boolean | Array<string | boolean>;
1685
+ };
1686
+ positionals: string[];
1687
+ tokens?: Token[];
1688
+ }
1689
+ : PreciseParsedResults<T>;
1690
+
1691
+ /**
1692
+ * An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/).
1693
+ *
1694
+ * In accordance with browser conventions, all properties of `MIMEType` objects
1695
+ * are implemented as getters and setters on the class prototype, rather than as
1696
+ * data properties on the object itself.
1697
+ *
1698
+ * A MIME string is a structured string containing multiple meaningful
1699
+ * components. When parsed, a `MIMEType` object is returned containing
1700
+ * properties for each of these components.
1701
+ * @since v19.1.0, v18.13.0
1702
+ * @experimental
1703
+ */
1704
+ export class MIMEType {
1705
+ /**
1706
+ * Creates a new MIMEType object by parsing the input.
1707
+ *
1708
+ * A `TypeError` will be thrown if the `input` is not a valid MIME.
1709
+ * Note that an effort will be made to coerce the given values into strings.
1710
+ * @param input The input MIME to parse.
1711
+ */
1712
+ constructor(input: string | { toString: () => string });
1713
+
1714
+ /**
1715
+ * Gets and sets the type portion of the MIME.
1716
+ *
1717
+ * ```js
1718
+ * import { MIMEType } from 'node:util';
1719
+ *
1720
+ * const myMIME = new MIMEType('text/javascript');
1721
+ * console.log(myMIME.type);
1722
+ * // Prints: text
1723
+ * myMIME.type = 'application';
1724
+ * console.log(myMIME.type);
1725
+ * // Prints: application
1726
+ * console.log(String(myMIME));
1727
+ * // Prints: application/javascript
1728
+ * ```
1729
+ */
1730
+ type: string;
1731
+ /**
1732
+ * Gets and sets the subtype portion of the MIME.
1733
+ *
1734
+ * ```js
1735
+ * import { MIMEType } from 'node:util';
1736
+ *
1737
+ * const myMIME = new MIMEType('text/ecmascript');
1738
+ * console.log(myMIME.subtype);
1739
+ * // Prints: ecmascript
1740
+ * myMIME.subtype = 'javascript';
1741
+ * console.log(myMIME.subtype);
1742
+ * // Prints: javascript
1743
+ * console.log(String(myMIME));
1744
+ * // Prints: text/javascript
1745
+ * ```
1746
+ */
1747
+ subtype: string;
1748
+ /**
1749
+ * Gets the essence of the MIME. This property is read only.
1750
+ * Use `mime.type` or `mime.subtype` to alter the MIME.
1751
+ *
1752
+ * ```js
1753
+ * import { MIMEType } from 'node:util';
1754
+ *
1755
+ * const myMIME = new MIMEType('text/javascript;key=value');
1756
+ * console.log(myMIME.essence);
1757
+ * // Prints: text/javascript
1758
+ * myMIME.type = 'application';
1759
+ * console.log(myMIME.essence);
1760
+ * // Prints: application/javascript
1761
+ * console.log(String(myMIME));
1762
+ * // Prints: application/javascript;key=value
1763
+ * ```
1764
+ */
1765
+ readonly essence: string;
1766
+ /**
1767
+ * Gets the `MIMEParams` object representing the
1768
+ * parameters of the MIME. This property is read-only. See `MIMEParams` documentation for details.
1769
+ */
1770
+ readonly params: MIMEParams;
1771
+ /**
1772
+ * The `toString()` method on the `MIMEType` object returns the serialized MIME.
1773
+ *
1774
+ * Because of the need for standard compliance, this method does not allow users
1775
+ * to customize the serialization process of the MIME.
1776
+ */
1777
+ toString(): string;
1778
+ }
1779
+ /**
1780
+ * The `MIMEParams` API provides read and write access to the parameters of a `MIMEType`.
1781
+ * @since v19.1.0, v18.13.0
1782
+ */
1783
+ export class MIMEParams {
1784
+ /**
1785
+ * Remove all name-value pairs whose name is `name`.
1786
+ */
1787
+ delete(name: string): void;
1788
+ /**
1789
+ * Returns an iterator over each of the name-value pairs in the parameters.
1790
+ * Each item of the iterator is a JavaScript `Array`. The first item of the array
1791
+ * is the `name`, the second item of the array is the `value`.
1792
+ */
1793
+ entries(): NodeJS.Iterator<[name: string, value: string]>;
1794
+ /**
1795
+ * Returns the value of the first name-value pair whose name is `name`. If there
1796
+ * are no such pairs, `null` is returned.
1797
+ * @return or `null` if there is no name-value pair with the given `name`.
1798
+ */
1799
+ get(name: string): string | null;
1800
+ /**
1801
+ * Returns `true` if there is at least one name-value pair whose name is `name`.
1802
+ */
1803
+ has(name: string): boolean;
1804
+ /**
1805
+ * Returns an iterator over the names of each name-value pair.
1806
+ *
1807
+ * ```js
1808
+ * import { MIMEType } from 'node:util';
1809
+ *
1810
+ * const { params } = new MIMEType('text/plain;foo=0;bar=1');
1811
+ * for (const name of params.keys()) {
1812
+ * console.log(name);
1813
+ * }
1814
+ * // Prints:
1815
+ * // foo
1816
+ * // bar
1817
+ * ```
1818
+ */
1819
+ keys(): NodeJS.Iterator<string>;
1820
+ /**
1821
+ * Sets the value in the `MIMEParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
1822
+ * set the first such pair's value to `value`.
1823
+ *
1824
+ * ```js
1825
+ * import { MIMEType } from 'node:util';
1826
+ *
1827
+ * const { params } = new MIMEType('text/plain;foo=0;bar=1');
1828
+ * params.set('foo', 'def');
1829
+ * params.set('baz', 'xyz');
1830
+ * console.log(params.toString());
1831
+ * // Prints: foo=def;bar=1;baz=xyz
1832
+ * ```
1833
+ */
1834
+ set(name: string, value: string): void;
1835
+ /**
1836
+ * Returns an iterator over the values of each name-value pair.
1837
+ */
1838
+ values(): NodeJS.Iterator<string>;
1839
+ /**
1840
+ * Returns an iterator over each of the name-value pairs in the parameters.
1841
+ */
1842
+ [Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
1843
+ }
1844
+ }
1845
+ declare module "util/types" {
1846
+ import { KeyObject, webcrypto } from "node:crypto";
1847
+ /**
1848
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) or
1849
+ * [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
1850
+ *
1851
+ * See also `util.types.isArrayBuffer()` and `util.types.isSharedArrayBuffer()`.
1852
+ *
1853
+ * ```js
1854
+ * util.types.isAnyArrayBuffer(new ArrayBuffer()); // Returns true
1855
+ * util.types.isAnyArrayBuffer(new SharedArrayBuffer()); // Returns true
1856
+ * ```
1857
+ * @since v10.0.0
1858
+ */
1859
+ function isAnyArrayBuffer(object: unknown): object is ArrayBufferLike;
1860
+ /**
1861
+ * Returns `true` if the value is an `arguments` object.
1862
+ *
1863
+ * ```js
1864
+ * function foo() {
1865
+ * util.types.isArgumentsObject(arguments); // Returns true
1866
+ * }
1867
+ * ```
1868
+ * @since v10.0.0
1869
+ */
1870
+ function isArgumentsObject(object: unknown): object is IArguments;
1871
+ /**
1872
+ * Returns `true` if the value is a built-in [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instance.
1873
+ * This does _not_ include [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instances. Usually, it is
1874
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
1875
+ *
1876
+ * ```js
1877
+ * util.types.isArrayBuffer(new ArrayBuffer()); // Returns true
1878
+ * util.types.isArrayBuffer(new SharedArrayBuffer()); // Returns false
1879
+ * ```
1880
+ * @since v10.0.0
1881
+ */
1882
+ function isArrayBuffer(object: unknown): object is ArrayBuffer;
1883
+ /**
1884
+ * 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
1885
+ * array objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent to
1886
+ * [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1887
+ *
1888
+ * ```js
1889
+ * util.types.isArrayBufferView(new Int8Array()); // true
1890
+ * util.types.isArrayBufferView(Buffer.from('hello world')); // true
1891
+ * util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true
1892
+ * util.types.isArrayBufferView(new ArrayBuffer()); // false
1893
+ * ```
1894
+ * @since v10.0.0
1895
+ */
1896
+ function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
1897
+ /**
1898
+ * Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
1899
+ * This only reports back what the JavaScript engine is seeing;
1900
+ * in particular, the return value may not match the original source code if
1901
+ * a transpilation tool was used.
1902
+ *
1903
+ * ```js
1904
+ * util.types.isAsyncFunction(function foo() {}); // Returns false
1905
+ * util.types.isAsyncFunction(async function foo() {}); // Returns true
1906
+ * ```
1907
+ * @since v10.0.0
1908
+ */
1909
+ function isAsyncFunction(object: unknown): boolean;
1910
+ /**
1911
+ * Returns `true` if the value is a `BigInt64Array` instance.
1912
+ *
1913
+ * ```js
1914
+ * util.types.isBigInt64Array(new BigInt64Array()); // Returns true
1915
+ * util.types.isBigInt64Array(new BigUint64Array()); // Returns false
1916
+ * ```
1917
+ * @since v10.0.0
1918
+ */
1919
+ function isBigInt64Array(value: unknown): value is BigInt64Array;
1920
+ /**
1921
+ * Returns `true` if the value is a `BigUint64Array` instance.
1922
+ *
1923
+ * ```js
1924
+ * util.types.isBigUint64Array(new BigInt64Array()); // Returns false
1925
+ * util.types.isBigUint64Array(new BigUint64Array()); // Returns true
1926
+ * ```
1927
+ * @since v10.0.0
1928
+ */
1929
+ function isBigUint64Array(value: unknown): value is BigUint64Array;
1930
+ /**
1931
+ * Returns `true` if the value is a boolean object, e.g. created
1932
+ * by `new Boolean()`.
1933
+ *
1934
+ * ```js
1935
+ * util.types.isBooleanObject(false); // Returns false
1936
+ * util.types.isBooleanObject(true); // Returns false
1937
+ * util.types.isBooleanObject(new Boolean(false)); // Returns true
1938
+ * util.types.isBooleanObject(new Boolean(true)); // Returns true
1939
+ * util.types.isBooleanObject(Boolean(false)); // Returns false
1940
+ * util.types.isBooleanObject(Boolean(true)); // Returns false
1941
+ * ```
1942
+ * @since v10.0.0
1943
+ */
1944
+ function isBooleanObject(object: unknown): object is Boolean;
1945
+ /**
1946
+ * Returns `true` if the value is any boxed primitive object, e.g. created
1947
+ * by `new Boolean()`, `new String()` or `Object(Symbol())`.
1948
+ *
1949
+ * For example:
1950
+ *
1951
+ * ```js
1952
+ * util.types.isBoxedPrimitive(false); // Returns false
1953
+ * util.types.isBoxedPrimitive(new Boolean(false)); // Returns true
1954
+ * util.types.isBoxedPrimitive(Symbol('foo')); // Returns false
1955
+ * util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true
1956
+ * util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true
1957
+ * ```
1958
+ * @since v10.11.0
1959
+ */
1960
+ function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
1961
+ /**
1962
+ * Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
1963
+ *
1964
+ * ```js
1965
+ * const ab = new ArrayBuffer(20);
1966
+ * util.types.isDataView(new DataView(ab)); // Returns true
1967
+ * util.types.isDataView(new Float64Array()); // Returns false
1968
+ * ```
1969
+ *
1970
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
1971
+ * @since v10.0.0
1972
+ */
1973
+ function isDataView(object: unknown): object is DataView;
1974
+ /**
1975
+ * Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance.
1976
+ *
1977
+ * ```js
1978
+ * util.types.isDate(new Date()); // Returns true
1979
+ * ```
1980
+ * @since v10.0.0
1981
+ */
1982
+ function isDate(object: unknown): object is Date;
1983
+ /**
1984
+ * Returns `true` if the value is a native `External` value.
1985
+ *
1986
+ * A native `External` value is a special type of object that contains a
1987
+ * raw C++ pointer (`void*`) for access from native code, and has no other
1988
+ * properties. Such objects are created either by Node.js internals or native
1989
+ * 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.
1990
+ *
1991
+ * ```c
1992
+ * #include <js_native_api.h>
1993
+ * #include <stdlib.h>
1994
+ * napi_value result;
1995
+ * static napi_value MyNapi(napi_env env, napi_callback_info info) {
1996
+ * int* raw = (int*) malloc(1024);
1997
+ * napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &#x26;result);
1998
+ * if (status != napi_ok) {
1999
+ * napi_throw_error(env, NULL, "napi_create_external failed");
2000
+ * return NULL;
2001
+ * }
2002
+ * return result;
2003
+ * }
2004
+ * ...
2005
+ * DECLARE_NAPI_PROPERTY("myNapi", MyNapi)
2006
+ * ...
2007
+ * ```
2008
+ *
2009
+ * ```js
2010
+ * const native = require('napi_addon.node');
2011
+ * const data = native.myNapi();
2012
+ * util.types.isExternal(data); // returns true
2013
+ * util.types.isExternal(0); // returns false
2014
+ * util.types.isExternal(new String('foo')); // returns false
2015
+ * ```
2016
+ *
2017
+ * For further information on `napi_create_external`, refer to `napi_create_external()`.
2018
+ * @since v10.0.0
2019
+ */
2020
+ function isExternal(object: unknown): boolean;
2021
+ /**
2022
+ * Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
2023
+ *
2024
+ * ```js
2025
+ * util.types.isFloat32Array(new ArrayBuffer()); // Returns false
2026
+ * util.types.isFloat32Array(new Float32Array()); // Returns true
2027
+ * util.types.isFloat32Array(new Float64Array()); // Returns false
2028
+ * ```
2029
+ * @since v10.0.0
2030
+ */
2031
+ function isFloat32Array(object: unknown): object is Float32Array;
2032
+ /**
2033
+ * Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance.
2034
+ *
2035
+ * ```js
2036
+ * util.types.isFloat64Array(new ArrayBuffer()); // Returns false
2037
+ * util.types.isFloat64Array(new Uint8Array()); // Returns false
2038
+ * util.types.isFloat64Array(new Float64Array()); // Returns true
2039
+ * ```
2040
+ * @since v10.0.0
2041
+ */
2042
+ function isFloat64Array(object: unknown): object is Float64Array;
2043
+ /**
2044
+ * Returns `true` if the value is a generator function.
2045
+ * This only reports back what the JavaScript engine is seeing;
2046
+ * in particular, the return value may not match the original source code if
2047
+ * a transpilation tool was used.
2048
+ *
2049
+ * ```js
2050
+ * util.types.isGeneratorFunction(function foo() {}); // Returns false
2051
+ * util.types.isGeneratorFunction(function* foo() {}); // Returns true
2052
+ * ```
2053
+ * @since v10.0.0
2054
+ */
2055
+ function isGeneratorFunction(object: unknown): object is GeneratorFunction;
2056
+ /**
2057
+ * Returns `true` if the value is a generator object as returned from a
2058
+ * built-in generator function.
2059
+ * This only reports back what the JavaScript engine is seeing;
2060
+ * in particular, the return value may not match the original source code if
2061
+ * a transpilation tool was used.
2062
+ *
2063
+ * ```js
2064
+ * function* foo() {}
2065
+ * const generator = foo();
2066
+ * util.types.isGeneratorObject(generator); // Returns true
2067
+ * ```
2068
+ * @since v10.0.0
2069
+ */
2070
+ function isGeneratorObject(object: unknown): object is Generator;
2071
+ /**
2072
+ * Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance.
2073
+ *
2074
+ * ```js
2075
+ * util.types.isInt8Array(new ArrayBuffer()); // Returns false
2076
+ * util.types.isInt8Array(new Int8Array()); // Returns true
2077
+ * util.types.isInt8Array(new Float64Array()); // Returns false
2078
+ * ```
2079
+ * @since v10.0.0
2080
+ */
2081
+ function isInt8Array(object: unknown): object is Int8Array;
2082
+ /**
2083
+ * Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance.
2084
+ *
2085
+ * ```js
2086
+ * util.types.isInt16Array(new ArrayBuffer()); // Returns false
2087
+ * util.types.isInt16Array(new Int16Array()); // Returns true
2088
+ * util.types.isInt16Array(new Float64Array()); // Returns false
2089
+ * ```
2090
+ * @since v10.0.0
2091
+ */
2092
+ function isInt16Array(object: unknown): object is Int16Array;
2093
+ /**
2094
+ * Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance.
2095
+ *
2096
+ * ```js
2097
+ * util.types.isInt32Array(new ArrayBuffer()); // Returns false
2098
+ * util.types.isInt32Array(new Int32Array()); // Returns true
2099
+ * util.types.isInt32Array(new Float64Array()); // Returns false
2100
+ * ```
2101
+ * @since v10.0.0
2102
+ */
2103
+ function isInt32Array(object: unknown): object is Int32Array;
2104
+ /**
2105
+ * Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
2106
+ *
2107
+ * ```js
2108
+ * util.types.isMap(new Map()); // Returns true
2109
+ * ```
2110
+ * @since v10.0.0
2111
+ */
2112
+ function isMap<T>(
2113
+ object: T | {},
2114
+ ): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>)
2115
+ : Map<unknown, unknown>;
2116
+ /**
2117
+ * 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.
2118
+ *
2119
+ * ```js
2120
+ * const map = new Map();
2121
+ * util.types.isMapIterator(map.keys()); // Returns true
2122
+ * util.types.isMapIterator(map.values()); // Returns true
2123
+ * util.types.isMapIterator(map.entries()); // Returns true
2124
+ * util.types.isMapIterator(map[Symbol.iterator]()); // Returns true
2125
+ * ```
2126
+ * @since v10.0.0
2127
+ */
2128
+ function isMapIterator(object: unknown): boolean;
2129
+ /**
2130
+ * Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects).
2131
+ *
2132
+ * ```js
2133
+ * import * as ns from './a.js';
2134
+ *
2135
+ * util.types.isModuleNamespaceObject(ns); // Returns true
2136
+ * ```
2137
+ * @since v10.0.0
2138
+ */
2139
+ function isModuleNamespaceObject(value: unknown): boolean;
2140
+ /**
2141
+ * Returns `true` if the value was returned by the constructor of a [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
2142
+ *
2143
+ * ```js
2144
+ * console.log(util.types.isNativeError(new Error())); // true
2145
+ * console.log(util.types.isNativeError(new TypeError())); // true
2146
+ * console.log(util.types.isNativeError(new RangeError())); // true
2147
+ * ```
2148
+ *
2149
+ * Subclasses of the native error types are also native errors:
2150
+ *
2151
+ * ```js
2152
+ * class MyError extends Error {}
2153
+ * console.log(util.types.isNativeError(new MyError())); // true
2154
+ * ```
2155
+ *
2156
+ * A value being `instanceof` a native error class is not equivalent to `isNativeError()` returning `true` for that value. `isNativeError()` returns `true` for errors
2157
+ * which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false` for these errors:
2158
+ *
2159
+ * ```js
2160
+ * import vm from 'node:vm';
2161
+ * const context = vm.createContext({});
2162
+ * const myError = vm.runInContext('new Error()', context);
2163
+ * console.log(util.types.isNativeError(myError)); // true
2164
+ * console.log(myError instanceof Error); // false
2165
+ * ```
2166
+ *
2167
+ * Conversely, `isNativeError()` returns `false` for all objects which were not
2168
+ * returned by the constructor of a native error. That includes values
2169
+ * which are `instanceof` native errors:
2170
+ *
2171
+ * ```js
2172
+ * const myError = { __proto__: Error.prototype };
2173
+ * console.log(util.types.isNativeError(myError)); // false
2174
+ * console.log(myError instanceof Error); // true
2175
+ * ```
2176
+ * @since v10.0.0
2177
+ */
2178
+ function isNativeError(object: unknown): object is Error;
2179
+ /**
2180
+ * Returns `true` if the value is a number object, e.g. created
2181
+ * by `new Number()`.
2182
+ *
2183
+ * ```js
2184
+ * util.types.isNumberObject(0); // Returns false
2185
+ * util.types.isNumberObject(new Number(0)); // Returns true
2186
+ * ```
2187
+ * @since v10.0.0
2188
+ */
2189
+ function isNumberObject(object: unknown): object is Number;
2190
+ /**
2191
+ * Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
2192
+ *
2193
+ * ```js
2194
+ * util.types.isPromise(Promise.resolve(42)); // Returns true
2195
+ * ```
2196
+ * @since v10.0.0
2197
+ */
2198
+ function isPromise(object: unknown): object is Promise<unknown>;
2199
+ /**
2200
+ * Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance.
2201
+ *
2202
+ * ```js
2203
+ * const target = {};
2204
+ * const proxy = new Proxy(target, {});
2205
+ * util.types.isProxy(target); // Returns false
2206
+ * util.types.isProxy(proxy); // Returns true
2207
+ * ```
2208
+ * @since v10.0.0
2209
+ */
2210
+ function isProxy(object: unknown): boolean;
2211
+ /**
2212
+ * Returns `true` if the value is a regular expression object.
2213
+ *
2214
+ * ```js
2215
+ * util.types.isRegExp(/abc/); // Returns true
2216
+ * util.types.isRegExp(new RegExp('abc')); // Returns true
2217
+ * ```
2218
+ * @since v10.0.0
2219
+ */
2220
+ function isRegExp(object: unknown): object is RegExp;
2221
+ /**
2222
+ * Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
2223
+ *
2224
+ * ```js
2225
+ * util.types.isSet(new Set()); // Returns true
2226
+ * ```
2227
+ * @since v10.0.0
2228
+ */
2229
+ function isSet<T>(
2230
+ object: T | {},
2231
+ ): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
2232
+ /**
2233
+ * 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.
2234
+ *
2235
+ * ```js
2236
+ * const set = new Set();
2237
+ * util.types.isSetIterator(set.keys()); // Returns true
2238
+ * util.types.isSetIterator(set.values()); // Returns true
2239
+ * util.types.isSetIterator(set.entries()); // Returns true
2240
+ * util.types.isSetIterator(set[Symbol.iterator]()); // Returns true
2241
+ * ```
2242
+ * @since v10.0.0
2243
+ */
2244
+ function isSetIterator(object: unknown): boolean;
2245
+ /**
2246
+ * Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
2247
+ * This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is
2248
+ * desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
2249
+ *
2250
+ * ```js
2251
+ * util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false
2252
+ * util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true
2253
+ * ```
2254
+ * @since v10.0.0
2255
+ */
2256
+ function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
2257
+ /**
2258
+ * Returns `true` if the value is a string object, e.g. created
2259
+ * by `new String()`.
2260
+ *
2261
+ * ```js
2262
+ * util.types.isStringObject('foo'); // Returns false
2263
+ * util.types.isStringObject(new String('foo')); // Returns true
2264
+ * ```
2265
+ * @since v10.0.0
2266
+ */
2267
+ function isStringObject(object: unknown): object is String;
2268
+ /**
2269
+ * Returns `true` if the value is a symbol object, created
2270
+ * by calling `Object()` on a `Symbol` primitive.
2271
+ *
2272
+ * ```js
2273
+ * const symbol = Symbol('foo');
2274
+ * util.types.isSymbolObject(symbol); // Returns false
2275
+ * util.types.isSymbolObject(Object(symbol)); // Returns true
2276
+ * ```
2277
+ * @since v10.0.0
2278
+ */
2279
+ function isSymbolObject(object: unknown): object is Symbol;
2280
+ /**
2281
+ * Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
2282
+ *
2283
+ * ```js
2284
+ * util.types.isTypedArray(new ArrayBuffer()); // Returns false
2285
+ * util.types.isTypedArray(new Uint8Array()); // Returns true
2286
+ * util.types.isTypedArray(new Float64Array()); // Returns true
2287
+ * ```
2288
+ *
2289
+ * See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
2290
+ * @since v10.0.0
2291
+ */
2292
+ function isTypedArray(object: unknown): object is NodeJS.TypedArray;
2293
+ /**
2294
+ * Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance.
2295
+ *
2296
+ * ```js
2297
+ * util.types.isUint8Array(new ArrayBuffer()); // Returns false
2298
+ * util.types.isUint8Array(new Uint8Array()); // Returns true
2299
+ * util.types.isUint8Array(new Float64Array()); // Returns false
2300
+ * ```
2301
+ * @since v10.0.0
2302
+ */
2303
+ function isUint8Array(object: unknown): object is Uint8Array;
2304
+ /**
2305
+ * Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance.
2306
+ *
2307
+ * ```js
2308
+ * util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
2309
+ * util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true
2310
+ * util.types.isUint8ClampedArray(new Float64Array()); // Returns false
2311
+ * ```
2312
+ * @since v10.0.0
2313
+ */
2314
+ function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
2315
+ /**
2316
+ * Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance.
2317
+ *
2318
+ * ```js
2319
+ * util.types.isUint16Array(new ArrayBuffer()); // Returns false
2320
+ * util.types.isUint16Array(new Uint16Array()); // Returns true
2321
+ * util.types.isUint16Array(new Float64Array()); // Returns false
2322
+ * ```
2323
+ * @since v10.0.0
2324
+ */
2325
+ function isUint16Array(object: unknown): object is Uint16Array;
2326
+ /**
2327
+ * Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance.
2328
+ *
2329
+ * ```js
2330
+ * util.types.isUint32Array(new ArrayBuffer()); // Returns false
2331
+ * util.types.isUint32Array(new Uint32Array()); // Returns true
2332
+ * util.types.isUint32Array(new Float64Array()); // Returns false
2333
+ * ```
2334
+ * @since v10.0.0
2335
+ */
2336
+ function isUint32Array(object: unknown): object is Uint32Array;
2337
+ /**
2338
+ * Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance.
2339
+ *
2340
+ * ```js
2341
+ * util.types.isWeakMap(new WeakMap()); // Returns true
2342
+ * ```
2343
+ * @since v10.0.0
2344
+ */
2345
+ function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
2346
+ /**
2347
+ * Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance.
2348
+ *
2349
+ * ```js
2350
+ * util.types.isWeakSet(new WeakSet()); // Returns true
2351
+ * ```
2352
+ * @since v10.0.0
2353
+ */
2354
+ function isWeakSet(object: unknown): object is WeakSet<object>;
2355
+ /**
2356
+ * Returns `true` if `value` is a `KeyObject`, `false` otherwise.
2357
+ * @since v16.2.0
2358
+ */
2359
+ function isKeyObject(object: unknown): object is KeyObject;
2360
+ /**
2361
+ * Returns `true` if `value` is a `CryptoKey`, `false` otherwise.
2362
+ * @since v16.2.0
2363
+ */
2364
+ function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
2365
+ }
2366
+ declare module "node:util" {
2367
+ export * from "util";
2368
+ }
2369
+ declare module "node:util/types" {
2370
+ export * from "util/types";
2371
+ }