rahad-media-downloader 2.1.12 → 2.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. package/.cache/replit/modules/nodejs-20.res +1 -0
  2. package/.cache/replit/modules/replit.res +1 -0
  3. package/.cache/typescript/5.4/node_modules/.package-lock.json +185 -0
  4. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +21 -0
  5. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +48 -0
  6. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +29 -0
  7. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +35 -0
  8. package/.cache/typescript/5.4/node_modules/@types/domhandler/LICENSE +21 -0
  9. package/.cache/typescript/5.4/node_modules/@types/domhandler/README.md +92 -0
  10. package/.cache/typescript/5.4/node_modules/@types/domhandler/index.d.ts +73 -0
  11. package/.cache/typescript/5.4/node_modules/@types/domhandler/package.json +25 -0
  12. package/.cache/typescript/5.4/node_modules/@types/domutils/LICENSE +21 -0
  13. package/.cache/typescript/5.4/node_modules/@types/domutils/README.md +15 -0
  14. package/.cache/typescript/5.4/node_modules/@types/domutils/index.d.ts +124 -0
  15. package/.cache/typescript/5.4/node_modules/@types/domutils/package.json +27 -0
  16. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/LICENSE +21 -0
  17. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/README.md +15 -0
  18. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/index.d.ts +120 -0
  19. package/.cache/typescript/5.4/node_modules/@types/htmlparser2/package.json +45 -0
  20. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
  21. package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
  22. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
  23. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
  24. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
  25. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
  26. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1542 -0
  27. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
  29. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
  30. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4522 -0
  31. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
  32. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +545 -0
  33. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +473 -0
  34. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +853 -0
  35. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
  36. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
  37. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +884 -0
  38. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
  39. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
  40. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +411 -0
  41. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
  42. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1889 -0
  43. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
  44. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
  45. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
  46. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
  47. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
  48. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +996 -0
  49. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
  50. package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
  51. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
  52. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +645 -0
  53. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1747 -0
  54. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
  55. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
  56. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
  57. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
  58. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
  59. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
  60. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
  61. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
  62. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
  63. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
  64. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
  65. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1470 -0
  66. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
  67. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
  68. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
  69. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
  70. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
  71. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +944 -0
  72. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2276 -0
  73. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +764 -0
  74. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +921 -0
  75. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
  76. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +691 -0
  77. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
  78. package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +21 -0
  79. package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +15 -0
  80. package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +32 -0
  81. package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +238 -0
  82. package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +83 -0
  83. package/.cache/typescript/5.4/node_modules/@types/qs/LICENSE +21 -0
  84. package/.cache/typescript/5.4/node_modules/@types/qs/README.md +15 -0
  85. package/.cache/typescript/5.4/node_modules/@types/qs/index.d.ts +79 -0
  86. package/.cache/typescript/5.4/node_modules/@types/qs/package.json +65 -0
  87. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +21 -0
  88. package/.cache/typescript/5.4/node_modules/@types/request/README.md +15 -0
  89. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +395 -0
  90. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +19 -0
  91. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +350 -0
  92. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +350 -0
  93. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +51 -0
  94. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +2 -0
  95. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +483 -0
  96. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +10 -0
  97. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +68 -0
  98. package/.cache/typescript/5.4/node_modules/@types/request/package.json +70 -0
  99. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +21 -0
  100. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +15 -0
  101. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +321 -0
  102. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +35 -0
  103. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +21 -0
  104. package/.cache/typescript/5.4/node_modules/asynckit/README.md +233 -0
  105. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +76 -0
  106. package/.cache/typescript/5.4/node_modules/asynckit/index.js +6 -0
  107. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +29 -0
  108. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +34 -0
  109. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +26 -0
  110. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +75 -0
  111. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +91 -0
  112. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +25 -0
  113. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +25 -0
  114. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
  115. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +37 -0
  116. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +141 -0
  117. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +29 -0
  118. package/.cache/typescript/5.4/node_modules/asynckit/package.json +63 -0
  119. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +43 -0
  120. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +17 -0
  121. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +75 -0
  122. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +21 -0
  123. package/.cache/typescript/5.4/node_modules/combined-stream/License +19 -0
  124. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +138 -0
  125. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +208 -0
  126. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +25 -0
  127. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +17 -0
  128. package/.cache/typescript/5.4/node_modules/delayed-stream/License +19 -0
  129. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +7 -0
  130. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +141 -0
  131. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
  132. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +27 -0
  133. package/.cache/typescript/5.4/node_modules/domelementtype/LICENSE +11 -0
  134. package/.cache/typescript/5.4/node_modules/domelementtype/index.js +15 -0
  135. package/.cache/typescript/5.4/node_modules/domelementtype/package.json +16 -0
  136. package/.cache/typescript/5.4/node_modules/domelementtype/readme.md +1 -0
  137. package/.cache/typescript/5.4/node_modules/domhandler/.travis.yml +6 -0
  138. package/.cache/typescript/5.4/node_modules/domhandler/LICENSE +11 -0
  139. package/.cache/typescript/5.4/node_modules/domhandler/index.js +217 -0
  140. package/.cache/typescript/5.4/node_modules/domhandler/lib/element.js +20 -0
  141. package/.cache/typescript/5.4/node_modules/domhandler/lib/node.js +44 -0
  142. package/.cache/typescript/5.4/node_modules/domhandler/package.json +41 -0
  143. package/.cache/typescript/5.4/node_modules/domhandler/readme.md +116 -0
  144. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/01-basic.json +57 -0
  145. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  146. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  147. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  148. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  149. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  150. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  151. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  152. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  153. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  154. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  155. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  156. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  157. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  158. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  159. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  160. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  161. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  162. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  163. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  164. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  165. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  166. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/23-dom-lvl1.json +131 -0
  167. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/24-with-start-indices.json +85 -0
  168. package/.cache/typescript/5.4/node_modules/domhandler/test/cases/25-with-end-indices.json +86 -0
  169. package/.cache/typescript/5.4/node_modules/domhandler/test/tests.js +60 -0
  170. package/.cache/typescript/5.4/node_modules/form-data/License +19 -0
  171. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +358 -0
  172. package/.cache/typescript/5.4/node_modules/form-data/Readme.md +358 -0
  173. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +62 -0
  174. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +2 -0
  175. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +501 -0
  176. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +10 -0
  177. package/.cache/typescript/5.4/node_modules/form-data/package.json +68 -0
  178. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +507 -0
  179. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +23 -0
  180. package/.cache/typescript/5.4/node_modules/mime-db/README.md +100 -0
  181. package/.cache/typescript/5.4/node_modules/mime-db/db.json +8519 -0
  182. package/.cache/typescript/5.4/node_modules/mime-db/index.js +12 -0
  183. package/.cache/typescript/5.4/node_modules/mime-db/package.json +60 -0
  184. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +397 -0
  185. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +23 -0
  186. package/.cache/typescript/5.4/node_modules/mime-types/README.md +113 -0
  187. package/.cache/typescript/5.4/node_modules/mime-types/index.js +188 -0
  188. package/.cache/typescript/5.4/node_modules/mime-types/package.json +44 -0
  189. package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
  190. package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
  191. package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
  192. package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
  193. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
  194. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
  195. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
  196. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
  197. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
  198. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
  199. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
  200. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
  201. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  202. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
  203. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
  204. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
  205. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
  206. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
  207. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
  208. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  209. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
  210. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
  211. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
  212. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
  213. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
  214. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
  215. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
  216. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
  217. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  218. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
  219. package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
  220. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
  221. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
  222. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
  223. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
  224. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
  225. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
  226. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
  227. package/.cache/typescript/5.4/package-lock.json +197 -0
  228. package/.cache/typescript/5.4/package.json +1 -0
  229. package/README.md +61 -2
  230. package/index.js +1 -1
  231. package/package.json +11 -2
  232. package/.cache/replit/modules/nodejs-20:v36-20240502-f4453db.res +0 -1
  233. package/.cache/replit/modules/replit:v9-20240429-0325cbb.res +0 -1
@@ -0,0 +1,764 @@
1
+ /**
2
+ * The `node:v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
3
+ *
4
+ * ```js
5
+ * const v8 = require('node:v8');
6
+ * ```
7
+ * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/v8.js)
8
+ */
9
+ declare module "v8" {
10
+ import { Readable } from "node:stream";
11
+ interface HeapSpaceInfo {
12
+ space_name: string;
13
+ space_size: number;
14
+ space_used_size: number;
15
+ space_available_size: number;
16
+ physical_space_size: number;
17
+ }
18
+ // ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
19
+ type DoesZapCodeSpaceFlag = 0 | 1;
20
+ interface HeapInfo {
21
+ total_heap_size: number;
22
+ total_heap_size_executable: number;
23
+ total_physical_size: number;
24
+ total_available_size: number;
25
+ used_heap_size: number;
26
+ heap_size_limit: number;
27
+ malloced_memory: number;
28
+ peak_malloced_memory: number;
29
+ does_zap_garbage: DoesZapCodeSpaceFlag;
30
+ number_of_native_contexts: number;
31
+ number_of_detached_contexts: number;
32
+ total_global_handles_size: number;
33
+ used_global_handles_size: number;
34
+ external_memory: number;
35
+ }
36
+ interface HeapCodeStatistics {
37
+ code_and_metadata_size: number;
38
+ bytecode_and_metadata_size: number;
39
+ external_script_source_size: number;
40
+ }
41
+ interface HeapSnapshotOptions {
42
+ /**
43
+ * If true, expose internals in the heap snapshot.
44
+ * @default false
45
+ */
46
+ exposeInternals?: boolean;
47
+ /**
48
+ * If true, expose numeric values in artificial fields.
49
+ * @default false
50
+ */
51
+ exposeNumericValues?: boolean;
52
+ }
53
+ /**
54
+ * Returns an integer representing a version tag derived from the V8 version,
55
+ * command-line flags, and detected CPU features. This is useful for determining
56
+ * whether a `vm.Script` `cachedData` buffer is compatible with this instance
57
+ * of V8.
58
+ *
59
+ * ```js
60
+ * console.log(v8.cachedDataVersionTag()); // 3947234607
61
+ * // The value returned by v8.cachedDataVersionTag() is derived from the V8
62
+ * // version, command-line flags, and detected CPU features. Test that the value
63
+ * // does indeed update when flags are toggled.
64
+ * v8.setFlagsFromString('--allow_natives_syntax');
65
+ * console.log(v8.cachedDataVersionTag()); // 183726201
66
+ * ```
67
+ * @since v8.0.0
68
+ */
69
+ function cachedDataVersionTag(): number;
70
+ /**
71
+ * Returns an object with the following properties:
72
+ *
73
+ * `does_zap_garbage` is a 0/1 boolean, which signifies whether the `--zap_code_space` option is enabled or not. This makes V8 overwrite heap
74
+ * garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
75
+ * because it continuously touches all heap pages and that makes them less likely
76
+ * to get swapped out by the operating system.
77
+ *
78
+ * `number_of_native_contexts` The value of native\_context is the number of the
79
+ * top-level contexts currently active. Increase of this number over time indicates
80
+ * a memory leak.
81
+ *
82
+ * `number_of_detached_contexts` The value of detached\_context is the number
83
+ * of contexts that were detached and not yet garbage collected. This number
84
+ * being non-zero indicates a potential memory leak.
85
+ *
86
+ * `total_global_handles_size` The value of total\_global\_handles\_size is the
87
+ * total memory size of V8 global handles.
88
+ *
89
+ * `used_global_handles_size` The value of used\_global\_handles\_size is the
90
+ * used memory size of V8 global handles.
91
+ *
92
+ * `external_memory` The value of external\_memory is the memory size of array
93
+ * buffers and external strings.
94
+ *
95
+ * ```js
96
+ * {
97
+ * total_heap_size: 7326976,
98
+ * total_heap_size_executable: 4194304,
99
+ * total_physical_size: 7326976,
100
+ * total_available_size: 1152656,
101
+ * used_heap_size: 3476208,
102
+ * heap_size_limit: 1535115264,
103
+ * malloced_memory: 16384,
104
+ * peak_malloced_memory: 1127496,
105
+ * does_zap_garbage: 0,
106
+ * number_of_native_contexts: 1,
107
+ * number_of_detached_contexts: 0,
108
+ * total_global_handles_size: 8192,
109
+ * used_global_handles_size: 3296,
110
+ * external_memory: 318824
111
+ * }
112
+ * ```
113
+ * @since v1.0.0
114
+ */
115
+ function getHeapStatistics(): HeapInfo;
116
+ /**
117
+ * Returns statistics about the V8 heap spaces, i.e. the segments which make up
118
+ * the V8 heap. Neither the ordering of heap spaces, nor the availability of a
119
+ * heap space can be guaranteed as the statistics are provided via the
120
+ * V8 [`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
121
+ * next.
122
+ *
123
+ * The value returned is an array of objects containing the following properties:
124
+ *
125
+ * ```json
126
+ * [
127
+ * {
128
+ * "space_name": "new_space",
129
+ * "space_size": 2063872,
130
+ * "space_used_size": 951112,
131
+ * "space_available_size": 80824,
132
+ * "physical_space_size": 2063872
133
+ * },
134
+ * {
135
+ * "space_name": "old_space",
136
+ * "space_size": 3090560,
137
+ * "space_used_size": 2493792,
138
+ * "space_available_size": 0,
139
+ * "physical_space_size": 3090560
140
+ * },
141
+ * {
142
+ * "space_name": "code_space",
143
+ * "space_size": 1260160,
144
+ * "space_used_size": 644256,
145
+ * "space_available_size": 960,
146
+ * "physical_space_size": 1260160
147
+ * },
148
+ * {
149
+ * "space_name": "map_space",
150
+ * "space_size": 1094160,
151
+ * "space_used_size": 201608,
152
+ * "space_available_size": 0,
153
+ * "physical_space_size": 1094160
154
+ * },
155
+ * {
156
+ * "space_name": "large_object_space",
157
+ * "space_size": 0,
158
+ * "space_used_size": 0,
159
+ * "space_available_size": 1490980608,
160
+ * "physical_space_size": 0
161
+ * }
162
+ * ]
163
+ * ```
164
+ * @since v6.0.0
165
+ */
166
+ function getHeapSpaceStatistics(): HeapSpaceInfo[];
167
+ /**
168
+ * The `v8.setFlagsFromString()` method can be used to programmatically set
169
+ * V8 command-line flags. This method should be used with care. Changing settings
170
+ * after the VM has started may result in unpredictable behavior, including
171
+ * crashes and data loss; or it may simply do nothing.
172
+ *
173
+ * The V8 options available for a version of Node.js may be determined by running `node --v8-options`.
174
+ *
175
+ * Usage:
176
+ *
177
+ * ```js
178
+ * // Print GC events to stdout for one minute.
179
+ * const v8 = require('node:v8');
180
+ * v8.setFlagsFromString('--trace_gc');
181
+ * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
182
+ * ```
183
+ * @since v1.0.0
184
+ */
185
+ function setFlagsFromString(flags: string): void;
186
+ /**
187
+ * Generates a snapshot of the current V8 heap and returns a Readable
188
+ * Stream that may be used to read the JSON serialized representation.
189
+ * This JSON stream format is intended to be used with tools such as
190
+ * Chrome DevTools. The JSON schema is undocumented and specific to the
191
+ * V8 engine. Therefore, the schema may change from one version of V8 to the next.
192
+ *
193
+ * Creating a heap snapshot requires memory about twice the size of the heap at
194
+ * the time the snapshot is created. This results in the risk of OOM killers
195
+ * terminating the process.
196
+ *
197
+ * Generating a snapshot is a synchronous operation which blocks the event loop
198
+ * for a duration depending on the heap size.
199
+ *
200
+ * ```js
201
+ * // Print heap snapshot to the console
202
+ * const v8 = require('node:v8');
203
+ * const stream = v8.getHeapSnapshot();
204
+ * stream.pipe(process.stdout);
205
+ * ```
206
+ * @since v11.13.0
207
+ * @return A Readable containing the V8 heap snapshot.
208
+ */
209
+ function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
210
+ /**
211
+ * Generates a snapshot of the current V8 heap and writes it to a JSON
212
+ * file. This file is intended to be used with tools such as Chrome
213
+ * DevTools. The JSON schema is undocumented and specific to the V8
214
+ * engine, and may change from one version of V8 to the next.
215
+ *
216
+ * A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
217
+ * not contain any information about the workers, and vice versa.
218
+ *
219
+ * Creating a heap snapshot requires memory about twice the size of the heap at
220
+ * the time the snapshot is created. This results in the risk of OOM killers
221
+ * terminating the process.
222
+ *
223
+ * Generating a snapshot is a synchronous operation which blocks the event loop
224
+ * for a duration depending on the heap size.
225
+ *
226
+ * ```js
227
+ * const { writeHeapSnapshot } = require('node:v8');
228
+ * const {
229
+ * Worker,
230
+ * isMainThread,
231
+ * parentPort,
232
+ * } = require('node:worker_threads');
233
+ *
234
+ * if (isMainThread) {
235
+ * const worker = new Worker(__filename);
236
+ *
237
+ * worker.once('message', (filename) => {
238
+ * console.log(`worker heapdump: ${filename}`);
239
+ * // Now get a heapdump for the main thread.
240
+ * console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
241
+ * });
242
+ *
243
+ * // Tell the worker to create a heapdump.
244
+ * worker.postMessage('heapdump');
245
+ * } else {
246
+ * parentPort.once('message', (message) => {
247
+ * if (message === 'heapdump') {
248
+ * // Generate a heapdump for the worker
249
+ * // and return the filename to the parent.
250
+ * parentPort.postMessage(writeHeapSnapshot());
251
+ * }
252
+ * });
253
+ * }
254
+ * ```
255
+ * @since v11.13.0
256
+ * @param filename The file path where the V8 heap snapshot is to be saved. If not specified, a file name with the pattern `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
257
+ * generated, where `{pid}` will be the PID of the Node.js process, `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from the main Node.js thread or the id of a
258
+ * worker thread.
259
+ * @return The filename where the snapshot was saved.
260
+ */
261
+ function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
262
+ /**
263
+ * Get statistics about code and its metadata in the heap, see
264
+ * V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
265
+ * following properties:
266
+ *
267
+ * ```js
268
+ * {
269
+ * code_and_metadata_size: 212208,
270
+ * bytecode_and_metadata_size: 161368,
271
+ * external_script_source_size: 1410794,
272
+ * cpu_profiler_metadata_size: 0,
273
+ * }
274
+ * ```
275
+ * @since v12.8.0
276
+ */
277
+ function getHeapCodeStatistics(): HeapCodeStatistics;
278
+ /**
279
+ * @since v8.0.0
280
+ */
281
+ class Serializer {
282
+ /**
283
+ * Writes out a header, which includes the serialization format version.
284
+ */
285
+ writeHeader(): void;
286
+ /**
287
+ * Serializes a JavaScript value and adds the serialized representation to the
288
+ * internal buffer.
289
+ *
290
+ * This throws an error if `value` cannot be serialized.
291
+ */
292
+ writeValue(val: any): boolean;
293
+ /**
294
+ * Returns the stored internal buffer. This serializer should not be used once
295
+ * the buffer is released. Calling this method results in undefined behavior
296
+ * if a previous write has failed.
297
+ */
298
+ releaseBuffer(): Buffer;
299
+ /**
300
+ * Marks an `ArrayBuffer` as having its contents transferred out of band.
301
+ * Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
302
+ * @param id A 32-bit unsigned integer.
303
+ * @param arrayBuffer An `ArrayBuffer` instance.
304
+ */
305
+ transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
306
+ /**
307
+ * Write a raw 32-bit unsigned integer.
308
+ * For use inside of a custom `serializer._writeHostObject()`.
309
+ */
310
+ writeUint32(value: number): void;
311
+ /**
312
+ * Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
313
+ * For use inside of a custom `serializer._writeHostObject()`.
314
+ */
315
+ writeUint64(hi: number, lo: number): void;
316
+ /**
317
+ * Write a JS `number` value.
318
+ * For use inside of a custom `serializer._writeHostObject()`.
319
+ */
320
+ writeDouble(value: number): void;
321
+ /**
322
+ * Write raw bytes into the serializer's internal buffer. The deserializer
323
+ * will require a way to compute the length of the buffer.
324
+ * For use inside of a custom `serializer._writeHostObject()`.
325
+ */
326
+ writeRawBytes(buffer: NodeJS.TypedArray): void;
327
+ }
328
+ /**
329
+ * A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
330
+ * stores the part of their underlying `ArrayBuffer`s that they are referring to.
331
+ * @since v8.0.0
332
+ */
333
+ class DefaultSerializer extends Serializer {}
334
+ /**
335
+ * @since v8.0.0
336
+ */
337
+ class Deserializer {
338
+ constructor(data: NodeJS.TypedArray);
339
+ /**
340
+ * Reads and validates a header (including the format version).
341
+ * May, for example, reject an invalid or unsupported wire format. In that case,
342
+ * an `Error` is thrown.
343
+ */
344
+ readHeader(): boolean;
345
+ /**
346
+ * Deserializes a JavaScript value from the buffer and returns it.
347
+ */
348
+ readValue(): any;
349
+ /**
350
+ * Marks an `ArrayBuffer` as having its contents transferred out of band.
351
+ * Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
352
+ * `SharedArrayBuffer`s).
353
+ * @param id A 32-bit unsigned integer.
354
+ * @param arrayBuffer An `ArrayBuffer` instance.
355
+ */
356
+ transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
357
+ /**
358
+ * Reads the underlying wire format version. Likely mostly to be useful to
359
+ * legacy code reading old wire format versions. May not be called before `.readHeader()`.
360
+ */
361
+ getWireFormatVersion(): number;
362
+ /**
363
+ * Read a raw 32-bit unsigned integer and return it.
364
+ * For use inside of a custom `deserializer._readHostObject()`.
365
+ */
366
+ readUint32(): number;
367
+ /**
368
+ * Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]` with two 32-bit unsigned integer entries.
369
+ * For use inside of a custom `deserializer._readHostObject()`.
370
+ */
371
+ readUint64(): [number, number];
372
+ /**
373
+ * Read a JS `number` value.
374
+ * For use inside of a custom `deserializer._readHostObject()`.
375
+ */
376
+ readDouble(): number;
377
+ /**
378
+ * Read raw bytes from the deserializer's internal buffer. The `length` parameter
379
+ * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
380
+ * For use inside of a custom `deserializer._readHostObject()`.
381
+ */
382
+ readRawBytes(length: number): Buffer;
383
+ }
384
+ /**
385
+ * A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
386
+ * @since v8.0.0
387
+ */
388
+ class DefaultDeserializer extends Deserializer {}
389
+ /**
390
+ * Uses a `DefaultSerializer` to serialize `value` into a buffer.
391
+ *
392
+ * `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
393
+ * serialize a huge object which requires buffer
394
+ * larger than `buffer.constants.MAX_LENGTH`.
395
+ * @since v8.0.0
396
+ */
397
+ function serialize(value: any): Buffer;
398
+ /**
399
+ * Uses a `DefaultDeserializer` with default options to read a JS value
400
+ * from a buffer.
401
+ * @since v8.0.0
402
+ * @param buffer A buffer returned by {@link serialize}.
403
+ */
404
+ function deserialize(buffer: NodeJS.TypedArray): any;
405
+ /**
406
+ * The `v8.takeCoverage()` method allows the user to write the coverage started by `NODE_V8_COVERAGE` to disk on demand. This method can be invoked multiple
407
+ * times during the lifetime of the process. Each time the execution counter will
408
+ * be reset and a new coverage report will be written to the directory specified
409
+ * by `NODE_V8_COVERAGE`.
410
+ *
411
+ * When the process is about to exit, one last coverage will still be written to
412
+ * disk unless {@link stopCoverage} is invoked before the process exits.
413
+ * @since v15.1.0, v14.18.0, v12.22.0
414
+ */
415
+ function takeCoverage(): void;
416
+ /**
417
+ * The `v8.stopCoverage()` method allows the user to stop the coverage collection
418
+ * started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
419
+ * records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
420
+ * @since v15.1.0, v14.18.0, v12.22.0
421
+ */
422
+ function stopCoverage(): void;
423
+ /**
424
+ * The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
425
+ * `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
426
+ * @experimental
427
+ * @since v18.10.0, v16.18.0
428
+ */
429
+ function setHeapSnapshotNearHeapLimit(limit: number): void;
430
+ /**
431
+ * This API collects GC data in current thread.
432
+ * @since v19.6.0, v18.15.0
433
+ */
434
+ class GCProfiler {
435
+ /**
436
+ * Start collecting GC data.
437
+ * @since v19.6.0, v18.15.0
438
+ */
439
+ start(): void;
440
+ /**
441
+ * Stop collecting GC data and return an object. The content of object
442
+ * is as follows.
443
+ *
444
+ * ```json
445
+ * {
446
+ * "version": 1,
447
+ * "startTime": 1674059033862,
448
+ * "statistics": [
449
+ * {
450
+ * "gcType": "Scavenge",
451
+ * "beforeGC": {
452
+ * "heapStatistics": {
453
+ * "totalHeapSize": 5005312,
454
+ * "totalHeapSizeExecutable": 524288,
455
+ * "totalPhysicalSize": 5226496,
456
+ * "totalAvailableSize": 4341325216,
457
+ * "totalGlobalHandlesSize": 8192,
458
+ * "usedGlobalHandlesSize": 2112,
459
+ * "usedHeapSize": 4883840,
460
+ * "heapSizeLimit": 4345298944,
461
+ * "mallocedMemory": 254128,
462
+ * "externalMemory": 225138,
463
+ * "peakMallocedMemory": 181760
464
+ * },
465
+ * "heapSpaceStatistics": [
466
+ * {
467
+ * "spaceName": "read_only_space",
468
+ * "spaceSize": 0,
469
+ * "spaceUsedSize": 0,
470
+ * "spaceAvailableSize": 0,
471
+ * "physicalSpaceSize": 0
472
+ * }
473
+ * ]
474
+ * },
475
+ * "cost": 1574.14,
476
+ * "afterGC": {
477
+ * "heapStatistics": {
478
+ * "totalHeapSize": 6053888,
479
+ * "totalHeapSizeExecutable": 524288,
480
+ * "totalPhysicalSize": 5500928,
481
+ * "totalAvailableSize": 4341101384,
482
+ * "totalGlobalHandlesSize": 8192,
483
+ * "usedGlobalHandlesSize": 2112,
484
+ * "usedHeapSize": 4059096,
485
+ * "heapSizeLimit": 4345298944,
486
+ * "mallocedMemory": 254128,
487
+ * "externalMemory": 225138,
488
+ * "peakMallocedMemory": 181760
489
+ * },
490
+ * "heapSpaceStatistics": [
491
+ * {
492
+ * "spaceName": "read_only_space",
493
+ * "spaceSize": 0,
494
+ * "spaceUsedSize": 0,
495
+ * "spaceAvailableSize": 0,
496
+ * "physicalSpaceSize": 0
497
+ * }
498
+ * ]
499
+ * }
500
+ * }
501
+ * ],
502
+ * "endTime": 1674059036865
503
+ * }
504
+ * ```
505
+ *
506
+ * Here's an example.
507
+ *
508
+ * ```js
509
+ * const { GCProfiler } = require('v8');
510
+ * const profiler = new GCProfiler();
511
+ * profiler.start();
512
+ * setTimeout(() => {
513
+ * console.log(profiler.stop());
514
+ * }, 1000);
515
+ * ```
516
+ * @since v19.6.0, v18.15.0
517
+ */
518
+ stop(): GCProfilerResult;
519
+ }
520
+ interface GCProfilerResult {
521
+ version: number;
522
+ startTime: number;
523
+ endTime: number;
524
+ statistics: Array<{
525
+ gcType: string;
526
+ cost: number;
527
+ beforeGC: {
528
+ heapStatistics: HeapStatistics;
529
+ heapSpaceStatistics: HeapSpaceStatistics[];
530
+ };
531
+ afterGC: {
532
+ heapStatistics: HeapStatistics;
533
+ heapSpaceStatistics: HeapSpaceStatistics[];
534
+ };
535
+ }>;
536
+ }
537
+ interface HeapStatistics {
538
+ totalHeapSize: number;
539
+ totalHeapSizeExecutable: number;
540
+ totalPhysicalSize: number;
541
+ totalAvailableSize: number;
542
+ totalGlobalHandlesSize: number;
543
+ usedGlobalHandlesSize: number;
544
+ usedHeapSize: number;
545
+ heapSizeLimit: number;
546
+ mallocedMemory: number;
547
+ externalMemory: number;
548
+ peakMallocedMemory: number;
549
+ }
550
+ interface HeapSpaceStatistics {
551
+ spaceName: string;
552
+ spaceSize: number;
553
+ spaceUsedSize: number;
554
+ spaceAvailableSize: number;
555
+ physicalSpaceSize: number;
556
+ }
557
+ /**
558
+ * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
559
+ * happen if a promise is created without ever getting a continuation.
560
+ * @since v17.1.0, v16.14.0
561
+ * @param promise The promise being created.
562
+ * @param parent The promise continued from, if applicable.
563
+ */
564
+ interface Init {
565
+ (promise: Promise<unknown>, parent: Promise<unknown>): void;
566
+ }
567
+ /**
568
+ * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
569
+ *
570
+ * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
571
+ * The before callback may be called many times in the case where many continuations have been made from the same promise.
572
+ * @since v17.1.0, v16.14.0
573
+ */
574
+ interface Before {
575
+ (promise: Promise<unknown>): void;
576
+ }
577
+ /**
578
+ * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
579
+ * @since v17.1.0, v16.14.0
580
+ */
581
+ interface After {
582
+ (promise: Promise<unknown>): void;
583
+ }
584
+ /**
585
+ * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
586
+ * {@link Promise.reject()}.
587
+ * @since v17.1.0, v16.14.0
588
+ */
589
+ interface Settled {
590
+ (promise: Promise<unknown>): void;
591
+ }
592
+ /**
593
+ * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
594
+ * around an await, and when the promise resolves or rejects.
595
+ *
596
+ * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
597
+ * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
598
+ * @since v17.1.0, v16.14.0
599
+ */
600
+ interface HookCallbacks {
601
+ init?: Init;
602
+ before?: Before;
603
+ after?: After;
604
+ settled?: Settled;
605
+ }
606
+ interface PromiseHooks {
607
+ /**
608
+ * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
609
+ * @since v17.1.0, v16.14.0
610
+ * @param init The {@link Init | `init` callback} to call when a promise is created.
611
+ * @return Call to stop the hook.
612
+ */
613
+ onInit: (init: Init) => Function;
614
+ /**
615
+ * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
616
+ * @since v17.1.0, v16.14.0
617
+ * @param settled The {@link Settled | `settled` callback} to call when a promise is created.
618
+ * @return Call to stop the hook.
619
+ */
620
+ onSettled: (settled: Settled) => Function;
621
+ /**
622
+ * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
623
+ * @since v17.1.0, v16.14.0
624
+ * @param before The {@link Before | `before` callback} to call before a promise continuation executes.
625
+ * @return Call to stop the hook.
626
+ */
627
+ onBefore: (before: Before) => Function;
628
+ /**
629
+ * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
630
+ * @since v17.1.0, v16.14.0
631
+ * @param after The {@link After | `after` callback} to call after a promise continuation executes.
632
+ * @return Call to stop the hook.
633
+ */
634
+ onAfter: (after: After) => Function;
635
+ /**
636
+ * Registers functions to be called for different lifetime events of each promise.
637
+ * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
638
+ * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
639
+ * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
640
+ * @since v17.1.0, v16.14.0
641
+ * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
642
+ * @return Used for disabling hooks
643
+ */
644
+ createHook: (callbacks: HookCallbacks) => Function;
645
+ }
646
+ /**
647
+ * The `promiseHooks` interface can be used to track promise lifecycle events.
648
+ * @since v17.1.0, v16.14.0
649
+ */
650
+ const promiseHooks: PromiseHooks;
651
+ type StartupSnapshotCallbackFn = (args: any) => any;
652
+ interface StartupSnapshot {
653
+ /**
654
+ * Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
655
+ * This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
656
+ * @since v18.6.0, v16.17.0
657
+ */
658
+ addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
659
+ /**
660
+ * Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
661
+ * The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
662
+ * to re-acquire resources that the application needs when the application is restarted from the snapshot.
663
+ * @since v18.6.0, v16.17.0
664
+ */
665
+ addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
666
+ /**
667
+ * This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
668
+ * If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
669
+ * data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
670
+ * @since v18.6.0, v16.17.0
671
+ */
672
+ setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
673
+ /**
674
+ * Returns true if the Node.js instance is run to build a snapshot.
675
+ * @since v18.6.0, v16.17.0
676
+ */
677
+ isBuildingSnapshot(): boolean;
678
+ }
679
+ /**
680
+ * The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
681
+ *
682
+ * ```bash
683
+ * $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
684
+ * # This launches a process with the snapshot
685
+ * $ node --snapshot-blob snapshot.blob
686
+ * ```
687
+ *
688
+ * In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
689
+ * in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
690
+ * For example, if the `entry.js` contains the following script:
691
+ *
692
+ * ```js
693
+ * 'use strict';
694
+ *
695
+ * const fs = require('node:fs');
696
+ * const zlib = require('node:zlib');
697
+ * const path = require('node:path');
698
+ * const assert = require('node:assert');
699
+ *
700
+ * const v8 = require('node:v8');
701
+ *
702
+ * class BookShelf {
703
+ * storage = new Map();
704
+ *
705
+ * // Reading a series of files from directory and store them into storage.
706
+ * constructor(directory, books) {
707
+ * for (const book of books) {
708
+ * this.storage.set(book, fs.readFileSync(path.join(directory, book)));
709
+ * }
710
+ * }
711
+ *
712
+ * static compressAll(shelf) {
713
+ * for (const [ book, content ] of shelf.storage) {
714
+ * shelf.storage.set(book, zlib.gzipSync(content));
715
+ * }
716
+ * }
717
+ *
718
+ * static decompressAll(shelf) {
719
+ * for (const [ book, content ] of shelf.storage) {
720
+ * shelf.storage.set(book, zlib.gunzipSync(content));
721
+ * }
722
+ * }
723
+ * }
724
+ *
725
+ * // __dirname here is where the snapshot script is placed
726
+ * // during snapshot building time.
727
+ * const shelf = new BookShelf(__dirname, [
728
+ * 'book1.en_US.txt',
729
+ * 'book1.es_ES.txt',
730
+ * 'book2.zh_CN.txt',
731
+ * ]);
732
+ *
733
+ * assert(v8.startupSnapshot.isBuildingSnapshot());
734
+ * // On snapshot serialization, compress the books to reduce size.
735
+ * v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
736
+ * // On snapshot deserialization, decompress the books.
737
+ * v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
738
+ * v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
739
+ * // process.env and process.argv are refreshed during snapshot
740
+ * // deserialization.
741
+ * const lang = process.env.BOOK_LANG || 'en_US';
742
+ * const book = process.argv[1];
743
+ * const name = `${book}.${lang}.txt`;
744
+ * console.log(shelf.storage.get(name));
745
+ * }, shelf);
746
+ * ```
747
+ *
748
+ * The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
749
+ *
750
+ * ```bash
751
+ * $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
752
+ * # Prints content of book1.es_ES.txt deserialized from the snapshot.
753
+ * ```
754
+ *
755
+ * Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
756
+ *
757
+ * @experimental
758
+ * @since v18.6.0, v16.17.0
759
+ */
760
+ const startupSnapshot: StartupSnapshot;
761
+ }
762
+ declare module "node:v8" {
763
+ export * from "v8";
764
+ }