daiki-fca 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

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