create-leo-app 0.9.3 → 0.9.4

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