{
  "type": "module",
  "source": "doc/api/v8.md",
  "modules": [
    {
      "textRaw": "V8",
      "name": "v8",
      "introduced_in": "v4.0.0",
      "type": "module",
      "desc": "<p>The <code>node:v8</code> module exposes APIs that are specific to the version of <a href=\"https://developers.google.com/v8/\">V8</a>\nbuilt into the Node.js binary. It can be accessed using:</p>\n<pre><code class=\"language-mjs\">import v8 from 'node:v8';\n</code></pre>\n<pre><code class=\"language-cjs\">const v8 = require('node:v8');\n</code></pre>",
      "methods": [
        {
          "textRaw": "`v8.cachedDataVersionTag()`",
          "name": "cachedDataVersionTag",
          "type": "method",
          "meta": {
            "added": [
              "v8.0.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {integer}",
                "name": "return",
                "type": "integer"
              }
            }
          ],
          "desc": "<p>Returns an integer representing a version tag derived from the V8 version,\ncommand-line flags, and detected CPU features. This is useful for determining\nwhether a <a href=\"vm.html#new-vmscriptcode-options\"><code>vm.Script</code></a> <code>cachedData</code> buffer is compatible with this instance\nof V8.</p>\n<pre><code class=\"language-js\">console.log(v8.cachedDataVersionTag()); // 3947234607\n// The value returned by v8.cachedDataVersionTag() is derived from the V8\n// version, command-line flags, and detected CPU features. Test that the value\n// does indeed update when flags are toggled.\nv8.setFlagsFromString('--allow_natives_syntax');\nconsole.log(v8.cachedDataVersionTag()); // 183726201\n</code></pre>"
        },
        {
          "textRaw": "`v8.getHeapCodeStatistics()`",
          "name": "getHeapCodeStatistics",
          "type": "method",
          "meta": {
            "added": [
              "v12.8.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {Object}",
                "name": "return",
                "type": "Object"
              }
            }
          ],
          "desc": "<p>Get statistics about code and its metadata in the heap, see V8\n<a href=\"https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866\"><code>GetHeapCodeAndMetadataStatistics</code></a> API. Returns an object with the\nfollowing properties:</p>\n<ul>\n<li><code>code_and_metadata_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>bytecode_and_metadata_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>external_script_source_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>cpu_profiler_metadata_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n</ul>\n<pre><code class=\"language-json\">{\n  \"code_and_metadata_size\": 212208,\n  \"bytecode_and_metadata_size\": 161368,\n  \"external_script_source_size\": 1410794,\n  \"cpu_profiler_metadata_size\": 0\n}\n</code></pre>"
        },
        {
          "textRaw": "`v8.getHeapSnapshot([options])`",
          "name": "getHeapSnapshot",
          "type": "method",
          "meta": {
            "added": [
              "v11.13.0"
            ],
            "changes": [
              {
                "version": "v19.1.0",
                "pr-url": "https://github.com/nodejs/node/pull/44989",
                "description": "Support options to configure the heap snapshot."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`exposeInternals` {boolean} If true, expose internals in the heap snapshot. **Default:** `false`.",
                      "name": "exposeInternals",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If true, expose internals in the heap snapshot."
                    },
                    {
                      "textRaw": "`exposeNumericValues` {boolean} If true, expose numeric values in artificial fields. **Default:** `false`.",
                      "name": "exposeNumericValues",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If true, expose numeric values in artificial fields."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {stream.Readable} A Readable containing the V8 heap snapshot.",
                "name": "return",
                "type": "stream.Readable",
                "desc": "A Readable containing the V8 heap snapshot."
              }
            }
          ],
          "desc": "<p>Generates a snapshot of the current V8 heap and returns a Readable\nStream that may be used to read the JSON serialized representation.\nThis JSON stream format is intended to be used with tools such as\nChrome DevTools. The JSON schema is undocumented and specific to the\nV8 engine. Therefore, the schema may change from one version of V8 to the next.</p>\n<p>Creating a heap snapshot requires memory about twice the size of the heap at\nthe time the snapshot is created. This results in the risk of OOM killers\nterminating the process.</p>\n<p>Generating a snapshot is a synchronous operation which blocks the event loop\nfor a duration depending on the heap size.</p>\n<pre><code class=\"language-mjs\">// Print heap snapshot to the console\nimport { getHeapSnapshot } from 'node:v8';\nimport process from 'node:process';\nconst stream = getHeapSnapshot();\nstream.pipe(process.stdout);\n</code></pre>\n<pre><code class=\"language-js\">// Print heap snapshot to the console\nconst v8 = require('node:v8');\nconst stream = v8.getHeapSnapshot();\nstream.pipe(process.stdout);\n</code></pre>"
        },
        {
          "textRaw": "`v8.getHeapSpaceStatistics()`",
          "name": "getHeapSpaceStatistics",
          "type": "method",
          "meta": {
            "added": [
              "v6.0.0"
            ],
            "changes": [
              {
                "version": "v7.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/10186",
                "description": "Support values exceeding the 32-bit unsigned integer range."
              }
            ]
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {Object[]}",
                "name": "return",
                "type": "Object[]"
              }
            }
          ],
          "desc": "<p>Returns statistics about the V8 heap spaces, i.e. the segments which make up\nthe V8 heap. Neither the ordering of heap spaces, nor the availability of a\nheap space can be guaranteed as the statistics are provided via the V8\n<a href=\"https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4\"><code>GetHeapSpaceStatistics</code></a> function and may change from one V8 version to the\nnext.</p>\n<p>The value returned is an array of objects containing the following properties:</p>\n<ul>\n<li><code>space_name</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a></li>\n<li><code>space_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>space_used_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>space_available_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>physical_space_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n</ul>\n<pre><code class=\"language-json\">[\n  {\n    \"space_name\": \"new_space\",\n    \"space_size\": 2063872,\n    \"space_used_size\": 951112,\n    \"space_available_size\": 80824,\n    \"physical_space_size\": 2063872\n  },\n  {\n    \"space_name\": \"old_space\",\n    \"space_size\": 3090560,\n    \"space_used_size\": 2493792,\n    \"space_available_size\": 0,\n    \"physical_space_size\": 3090560\n  },\n  {\n    \"space_name\": \"code_space\",\n    \"space_size\": 1260160,\n    \"space_used_size\": 644256,\n    \"space_available_size\": 960,\n    \"physical_space_size\": 1260160\n  },\n  {\n    \"space_name\": \"map_space\",\n    \"space_size\": 1094160,\n    \"space_used_size\": 201608,\n    \"space_available_size\": 0,\n    \"physical_space_size\": 1094160\n  },\n  {\n    \"space_name\": \"large_object_space\",\n    \"space_size\": 0,\n    \"space_used_size\": 0,\n    \"space_available_size\": 1490980608,\n    \"physical_space_size\": 0\n  }\n]\n</code></pre>"
        },
        {
          "textRaw": "`v8.getHeapStatistics()`",
          "name": "getHeapStatistics",
          "type": "method",
          "meta": {
            "added": [
              "v1.0.0"
            ],
            "changes": [
              {
                "version": "v7.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/10186",
                "description": "Support values exceeding the 32-bit unsigned integer range."
              },
              {
                "version": "v7.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/8610",
                "description": "Added `malloced_memory`, `peak_malloced_memory`, and `does_zap_garbage`."
              }
            ]
          },
          "signatures": [
            {
              "params": [],
              "return": {
                "textRaw": "Returns: {Object}",
                "name": "return",
                "type": "Object"
              }
            }
          ],
          "desc": "<p>Returns an object with the following properties:</p>\n<ul>\n<li><code>total_heap_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>total_heap_size_executable</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>total_physical_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>total_available_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>used_heap_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>heap_size_limit</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>malloced_memory</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>peak_malloced_memory</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>does_zap_garbage</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>number_of_native_contexts</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>number_of_detached_contexts</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>total_global_handles_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>used_global_handles_size</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>external_memory</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n<li><code>total_allocated_bytes</code> <a href=\"https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type\"><code>&#x3C;number></code></a></li>\n</ul>\n<p><code>total_heap_size</code> The value of total_heap_size is the number of bytes V8 has\nallocated for the heap. This can grow if used_heap needs more memory.</p>\n<p><code>total_heap_size_executable</code> The value of total_heap_size_executable is the\nportion of the heap that can contain executable code, in bytes. This includes\nmemory used by JIT-compiled code and any memory that must be kept executable.</p>\n<p><code>total_physical_size</code> The value of total_physical_size is the actual physical memory\nused by the V8 heap, in bytes. This is the amount of memory that is committed\n(or in use) rather than reserved.</p>\n<p><code>total_available_size</code> The value of total_available_size is the number of\nbytes of memory available to the V8 heap. This value represents how much\nmore memory V8 can use before it exceeds the heap limit.</p>\n<p><code>used_heap_size</code> The value of used_heap_size is number of bytes currently\nbeing used by V8’s JavaScript objects. This is the actual memory in use and\ndoes not include memory that has been allocated but not yet used.</p>\n<p><code>heap_size_limit</code> The value of heap_size_limit is the maximum size of the V8\nheap, in bytes (either the default limit, determined by system resources, or\nthe value passed to the <code>--max_old_space_size</code> option).</p>\n<p><code>malloced_memory</code> The value of malloced_memory is the number of bytes allocated\nthrough <code>malloc</code> by V8.</p>\n<p><code>peak_malloced_memory</code> The value of peak_malloced_memory is the peak number of\nbytes allocated through <code>malloc</code> by V8 during the lifetime of the process.</p>\n<p><code>does_zap_garbage</code> is a 0/1 boolean, which signifies whether the\n<code>--zap_code_space</code> option is enabled or not. This makes V8 overwrite heap\ngarbage with a bit pattern. The RSS footprint (resident set size) gets bigger\nbecause it continuously touches all heap pages and that makes them less likely\nto get swapped out by the operating system.</p>\n<p><code>number_of_native_contexts</code> The value of native_context is the number of the\ntop-level contexts currently active. Increase of this number over time indicates\na memory leak.</p>\n<p><code>number_of_detached_contexts</code> The value of detached_context is the number\nof contexts that were detached and not yet garbage collected. This number\nbeing non-zero indicates a potential memory leak.</p>\n<p><code>total_global_handles_size</code> The value of total_global_handles_size is the\ntotal memory size of V8 global handles.</p>\n<p><code>used_global_handles_size</code> The value of used_global_handles_size is the\nused memory size of V8 global handles.</p>\n<p><code>external_memory</code> The value of external_memory is the memory size of array\nbuffers and external strings.</p>\n<p><code>total_allocated_bytes</code> The value of total allocated bytes since the Isolate\ncreation</p>\n<pre><code class=\"language-json\">{\n  \"total_heap_size\": 7326976,\n  \"total_heap_size_executable\": 4194304,\n  \"total_physical_size\": 7326976,\n  \"total_available_size\": 1152656,\n  \"used_heap_size\": 3476208,\n  \"heap_size_limit\": 1535115264,\n  \"malloced_memory\": 16384,\n  \"peak_malloced_memory\": 1127496,\n  \"does_zap_garbage\": 0,\n  \"number_of_native_contexts\": 1,\n  \"number_of_detached_contexts\": 0,\n  \"total_global_handles_size\": 8192,\n  \"used_global_handles_size\": 3296,\n  \"external_memory\": 318824\n}\n</code></pre>"
        },
        {
          "textRaw": "`v8.getCppHeapStatistics([detailLevel])`",
          "name": "getCppHeapStatistics",
          "type": "method",
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`detailLevel` {string|undefined}: **Default:** `'detailed'`. Specifies the level of detail in the returned statistics. Accepted values are:",
                  "name": "detailLevel",
                  "type": "string|undefined",
                  "default": "`'detailed'`. Specifies the level of detail in the returned statistics. Accepted values are:",
                  "desc": ":",
                  "options": [
                    {
                      "textRaw": "`'brief'`: Brief statistics contain only the top-level allocated and used memory statistics for the entire heap.",
                      "desc": "`'brief'`: Brief statistics contain only the top-level allocated and used memory statistics for the entire heap."
                    },
                    {
                      "textRaw": "`'detailed'`: Detailed statistics also contain a break down per space and page, as well as freelist statistics and object type histograms.",
                      "desc": "`'detailed'`: Detailed statistics also contain a break down per space and page, as well as freelist statistics and object type histograms."
                    }
                  ],
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Retrieves <a href=\"https://v8docs.nodesource.com/node-22.4/d9/dc4/classv8_1_1_cpp_heap.html\">CppHeap</a> statistics regarding memory consumption and\nutilization using the V8 <a href=\"https://v8docs.nodesource.com/node-22.4/d9/dc4/classv8_1_1_cpp_heap.html#a3a5d09567758e608fffde50eeabc2feb\"><code>CollectStatistics()</code></a> function which\nmay change from one V8 version to the\nnext.</p>\n<p>It returns an object with a structure similar to the\n<a href=\"https://v8docs.nodesource.com/node-22.4/d7/d51/heap-statistics_8h_source.html\"><code>cppgc::HeapStatistics</code></a> object. See the <a href=\"https://v8docs.nodesource.com/node-22.4/df/d2f/structcppgc_1_1_heap_statistics.html\">V8 documentation</a>\nfor more information about the properties of the object.</p>\n<pre><code class=\"language-js\">// Detailed\n({\n  committed_size_bytes: 131072,\n  resident_size_bytes: 131072,\n  used_size_bytes: 152,\n  space_statistics: [\n    {\n      name: 'NormalPageSpace0',\n      committed_size_bytes: 0,\n      resident_size_bytes: 0,\n      used_size_bytes: 0,\n      page_stats: [{}],\n      free_list_stats: {},\n    },\n    {\n      name: 'NormalPageSpace1',\n      committed_size_bytes: 131072,\n      resident_size_bytes: 131072,\n      used_size_bytes: 152,\n      page_stats: [{}],\n      free_list_stats: {},\n    },\n    {\n      name: 'NormalPageSpace2',\n      committed_size_bytes: 0,\n      resident_size_bytes: 0,\n      used_size_bytes: 0,\n      page_stats: [{}],\n      free_list_stats: {},\n    },\n    {\n      name: 'NormalPageSpace3',\n      committed_size_bytes: 0,\n      resident_size_bytes: 0,\n      used_size_bytes: 0,\n      page_stats: [{}],\n      free_list_stats: {},\n    },\n    {\n      name: 'LargePageSpace',\n      committed_size_bytes: 0,\n      resident_size_bytes: 0,\n      used_size_bytes: 0,\n      page_stats: [{}],\n      free_list_stats: {},\n    },\n  ],\n  type_names: [],\n  detail_level: 'detailed',\n});\n</code></pre>\n<pre><code class=\"language-js\">// Brief\n({\n  committed_size_bytes: 131072,\n  resident_size_bytes: 131072,\n  used_size_bytes: 128864,\n  space_statistics: [],\n  type_names: [],\n  detail_level: 'brief',\n});\n</code></pre>"
        },
        {
          "textRaw": "`v8.queryObjects(ctor[, options])`",
          "name": "queryObjects",
          "type": "method",
          "meta": {
            "added": [
              "v22.0.0",
              "v20.13.0"
            ],
            "changes": [
              {
                "version": [
                  "v25.4.0",
                  "v24.13.1"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/60957",
                "description": "This API is no longer experimental."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`ctor` {Function} The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.",
                  "name": "ctor",
                  "type": "Function",
                  "desc": "The constructor that can be used to search on the prototype chain in order to filter target objects in the heap."
                },
                {
                  "textRaw": "`options` {undefined|Object}",
                  "name": "options",
                  "type": "undefined|Object",
                  "options": [
                    {
                      "textRaw": "`format` {string} If it's `'count'`, the count of matched objects is returned. If it's `'summary'`, an array with summary strings of the matched objects is returned.",
                      "name": "format",
                      "type": "string",
                      "desc": "If it's `'count'`, the count of matched objects is returned. If it's `'summary'`, an array with summary strings of the matched objects is returned."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {number|string[]}",
                "name": "return",
                "type": "number|string[]"
              }
            }
          ],
          "desc": "<p>This is similar to the <a href=\"https://developer.chrome.com/docs/devtools/console/utilities#queryObjects-function\"><code>queryObjects()</code> console API</a> provided by the\nChromium DevTools console. It can be used to search for objects that\nhave the matching constructor on its prototype chain in the heap after\na full garbage collection, which can be useful for memory leak\nregression tests. To avoid surprising results, users should avoid using\nthis API on constructors whose implementation they don't control, or on\nconstructors that can be invoked by other parties in the application.</p>\n<p>To avoid accidental leaks, this API does not return raw references to\nthe objects found. By default, it returns the count of the objects\nfound. If <code>options.format</code> is <code>'summary'</code>, it returns an array\ncontaining brief string representations for each object. The visibility\nprovided in this API is similar to what the heap snapshot provides,\nwhile users can save the cost of serialization and parsing and directly\nfilter the target objects during the search.</p>\n<p>Only objects created in the current execution context are included in the\nresults.</p>\n<pre><code class=\"language-cjs\">const { queryObjects } = require('node:v8');\nclass A { foo = 'bar'; }\nconsole.log(queryObjects(A)); // 0\nconst a = new A();\nconsole.log(queryObjects(A)); // 1\n// [ \"A { foo: 'bar' }\" ]\nconsole.log(queryObjects(A, { format: 'summary' }));\n\nclass B extends A { bar = 'qux'; }\nconst b = new B();\nconsole.log(queryObjects(B)); // 1\n// [ \"B { foo: 'bar', bar: 'qux' }\" ]\nconsole.log(queryObjects(B, { format: 'summary' }));\n\n// Note that, when there are child classes inheriting from a constructor,\n// the constructor also shows up in the prototype chain of the child\n// classes's prototype, so the child classes's prototype would also be\n// included in the result.\nconsole.log(queryObjects(A));  // 3\n// [ \"B { foo: 'bar', bar: 'qux' }\", 'A {}', \"A { foo: 'bar' }\" ]\nconsole.log(queryObjects(A, { format: 'summary' }));\n</code></pre>\n<pre><code class=\"language-mjs\">import { queryObjects } from 'node:v8';\nclass A { foo = 'bar'; }\nconsole.log(queryObjects(A)); // 0\nconst a = new A();\nconsole.log(queryObjects(A)); // 1\n// [ \"A { foo: 'bar' }\" ]\nconsole.log(queryObjects(A, { format: 'summary' }));\n\nclass B extends A { bar = 'qux'; }\nconst b = new B();\nconsole.log(queryObjects(B)); // 1\n// [ \"B { foo: 'bar', bar: 'qux' }\" ]\nconsole.log(queryObjects(B, { format: 'summary' }));\n\n// Note that, when there are child classes inheriting from a constructor,\n// the constructor also shows up in the prototype chain of the child\n// classes's prototype, so the child classes's prototype would also be\n// included in the result.\nconsole.log(queryObjects(A));  // 3\n// [ \"B { foo: 'bar', bar: 'qux' }\", 'A {}', \"A { foo: 'bar' }\" ]\nconsole.log(queryObjects(A, { format: 'summary' }));\n</code></pre>"
        },
        {
          "textRaw": "`v8.setFlagsFromString(flags)`",
          "name": "setFlagsFromString",
          "type": "method",
          "meta": {
            "added": [
              "v1.0.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`flags` {string}",
                  "name": "flags",
                  "type": "string"
                }
              ]
            }
          ],
          "desc": "<p>The <code>v8.setFlagsFromString()</code> method can be used to programmatically set\nV8 command-line flags. This method should be used with care. Changing settings\nafter the VM has started may result in unpredictable behavior, including\ncrashes and data loss; or it may simply do nothing.</p>\n<p>The V8 options available for a version of Node.js may be determined by running\n<code>node --v8-options</code>.</p>\n<p>Usage:</p>\n<pre><code class=\"language-mjs\">import { setFlagsFromString } from 'node:v8';\nimport { setInterval } from 'node:timers';\n\n// setFlagsFromString to trace garbage collection events\nsetFlagsFromString('--trace-gc');\n\n// Trigger GC events by using some memory\nlet arrays = [];\nconst interval = setInterval(() => {\n  for (let i = 0; i &#x3C; 500; i++) {\n    arrays.push(new Array(10000).fill(Math.random()));\n  }\n\n  if (arrays.length > 5000) {\n    arrays = arrays.slice(-1000);\n  }\n\n  console.log(`\\n* Created ${arrays.length} arrays\\n`);\n}, 100);\n\n// setFlagsFromString to stop tracing GC events after 1.5 seconds\nsetTimeout(() => {\n  setFlagsFromString('--notrace-gc');\n  console.log('\\nStopped tracing!\\n');\n}, 1500);\n\n// Stop triggering GC events altogether after 2.5 seconds\nsetTimeout(() => {\n  clearInterval(interval);\n}, 2500);\n</code></pre>\n<pre><code class=\"language-cjs\">const { setFlagsFromString } = require('node:v8');\nconst { setInterval } = require('node:timers');\n\n// setFlagsFromString to trace garbage collection events\nsetFlagsFromString('--trace-gc');\n\n// Trigger GC events by using some memory\nlet arrays = [];\nconst interval = setInterval(() => {\n  for (let i = 0; i &#x3C; 500; i++) {\n    arrays.push(new Array(10000).fill(Math.random()));\n  }\n\n  if (arrays.length > 5000) {\n    arrays = arrays.slice(-1000);\n  }\n\n  console.log(`\\n* Created ${arrays.length} arrays\\n`);\n}, 100);\n\n// setFlagsFromString to stop tracing GC events after 1.5 seconds\nsetTimeout(() => {\n  console.log('\\nStopped tracing!\\n');\n  setFlagsFromString('--notrace-gc');\n}, 1500);\n\n// Stop triggering GC events altogether after 2.5 seconds\nsetTimeout(() => {\n  clearInterval(interval);\n}, 2500);\n</code></pre>"
        },
        {
          "textRaw": "`v8.stopCoverage()`",
          "name": "stopCoverage",
          "type": "method",
          "meta": {
            "added": [
              "v15.1.0",
              "v14.18.0",
              "v12.22.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>The <code>v8.stopCoverage()</code> method allows the user to stop the coverage collection\nstarted by <a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE</code></a>, so that V8 can release the execution count\nrecords and optimize code. This can be used in conjunction with\n<a href=\"#v8takecoverage\"><code>v8.takeCoverage()</code></a> if the user wants to collect the coverage on demand.</p>"
        },
        {
          "textRaw": "`v8.takeCoverage()`",
          "name": "takeCoverage",
          "type": "method",
          "meta": {
            "added": [
              "v15.1.0",
              "v14.18.0",
              "v12.22.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": []
            }
          ],
          "desc": "<p>The <code>v8.takeCoverage()</code> method allows the user to write the coverage started by\n<a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE</code></a> to disk on demand. This method can be invoked multiple\ntimes during the lifetime of the process. Each time the execution counter will\nbe reset and a new coverage report will be written to the directory specified\nby <a href=\"cli.html#node_v8_coveragedir\"><code>NODE_V8_COVERAGE</code></a>.</p>\n<p>When the process is about to exit, one last coverage will still be written to\ndisk unless <a href=\"#v8stopcoverage\"><code>v8.stopCoverage()</code></a> is invoked before the process exits.</p>"
        },
        {
          "textRaw": "`v8.writeHeapSnapshot([filename[,options]])`",
          "name": "writeHeapSnapshot",
          "type": "method",
          "meta": {
            "added": [
              "v11.13.0"
            ],
            "changes": [
              {
                "version": "v19.1.0",
                "pr-url": "https://github.com/nodejs/node/pull/44989",
                "description": "Support options to configure the heap snapshot."
              },
              {
                "version": "v18.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/41373",
                "description": "An exception will now be thrown if the file could not be written."
              },
              {
                "version": "v18.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/42577",
                "description": "Make the returned error codes consistent across all platforms."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`filename` {string} 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 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 worker thread.",
                  "name": "filename",
                  "type": "string",
                  "desc": "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 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 worker thread.",
                  "optional": true
                },
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`exposeInternals` {boolean} If true, expose internals in the heap snapshot. **Default:** `false`.",
                      "name": "exposeInternals",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If true, expose internals in the heap snapshot."
                    },
                    {
                      "textRaw": "`exposeNumericValues` {boolean} If true, expose numeric values in artificial fields. **Default:** `false`.",
                      "name": "exposeNumericValues",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "If true, expose numeric values in artificial fields."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {string} The filename where the snapshot was saved.",
                "name": "return",
                "type": "string",
                "desc": "The filename where the snapshot was saved."
              }
            }
          ],
          "desc": "<p>Generates a snapshot of the current V8 heap and writes it to a JSON\nfile. This file is intended to be used with tools such as Chrome\nDevTools. The JSON schema is undocumented and specific to the V8\nengine, and may change from one version of V8 to the next.</p>\n<p>A heap snapshot is specific to a single V8 isolate. When using\n<a href=\"worker_threads.html\">worker threads</a>, a heap snapshot generated from the main thread will\nnot contain any information about the workers, and vice versa.</p>\n<p>Creating a heap snapshot requires memory about twice the size of the heap at\nthe time the snapshot is created. This results in the risk of OOM killers\nterminating the process.</p>\n<p>Generating a snapshot is a synchronous operation which blocks the event loop\nfor a duration depending on the heap size.</p>\n<pre><code class=\"language-mjs\">import { writeHeapSnapshot } from 'node:v8';\nimport { Worker, isMainThread, parentPort } from 'node:worker_threads';\nimport { fileURLToPath } from 'node:url';\n\nif (isMainThread) {\n  const __filename = fileURLToPath(import.meta.url);\n  const worker = new Worker(__filename);\n\n  worker.once('message', (filename) => {\n    console.log(`worker heapdump: ${filename}`);\n    // Now get a heapdump for the main thread.\n    console.log(`main thread heapdump: ${writeHeapSnapshot()}`);\n  });\n\n  // Tell the worker to create a heapdump.\n  worker.postMessage('heapdump');\n} else {\n  parentPort.once('message', (message) => {\n    if (message === 'heapdump') {\n      // Generate a heapdump for the worker\n      // and return the filename to the parent.\n      parentPort.postMessage(writeHeapSnapshot());\n    }\n  });\n}\n</code></pre>\n<pre><code class=\"language-cjs\">const { writeHeapSnapshot } = require('node:v8');\nconst { Worker, isMainThread, parentPort } = require('node:worker_threads');\n\nif (isMainThread) {\n  const worker = new Worker(__filename);\n\n  worker.once('message', (filename) => {\n    console.log(`worker heapdump: ${filename}`);\n    // Now get a heapdump for the main thread.\n    console.log(`main thread heapdump: ${writeHeapSnapshot()}`);\n  });\n\n  // Tell the worker to create a heapdump.\n  worker.postMessage('heapdump');\n} else {\n  parentPort.once('message', (message) => {\n    if (message === 'heapdump') {\n      // Generate a heapdump for the worker\n      // and return the filename to the parent.\n      parentPort.postMessage(writeHeapSnapshot());\n    }\n  });\n}\n</code></pre>"
        },
        {
          "textRaw": "`v8.setHeapSnapshotNearHeapLimit(limit)`",
          "name": "setHeapSnapshotNearHeapLimit",
          "type": "method",
          "meta": {
            "added": [
              "v18.10.0",
              "v16.18.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`limit` {integer}",
                  "name": "limit",
                  "type": "integer"
                }
              ]
            }
          ],
          "desc": "<p>The API is a no-op if <code>--heapsnapshot-near-heap-limit</code> is already set from the\ncommand line or the API is called more than once. <code>limit</code> must be a positive\ninteger. See <a href=\"cli.html#--heapsnapshot-near-heap-limitmax_count\"><code>--heapsnapshot-near-heap-limit</code></a> for more information.</p>"
        },
        {
          "textRaw": "`v8.isStringOneByteRepresentation(content)`",
          "name": "isStringOneByteRepresentation",
          "type": "method",
          "meta": {
            "added": [
              "v23.10.0",
              "v22.15.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`content` {string}",
                  "name": "content",
                  "type": "string"
                }
              ],
              "return": {
                "textRaw": "Returns: {boolean}",
                "name": "return",
                "type": "boolean"
              }
            }
          ],
          "desc": "<p>V8 only supports <code>Latin-1/ISO-8859-1</code> and <code>UTF16</code> as the underlying representation of a string.\nIf the <code>content</code> uses <code>Latin-1/ISO-8859-1</code> as the underlying representation, this function will return true;\notherwise, it returns false.</p>\n<p>If this method returns false, that does not mean that the string contains some characters not in <code>Latin-1/ISO-8859-1</code>.\nSometimes a <code>Latin-1</code> string may also be represented as <code>UTF16</code>.</p>\n<pre><code class=\"language-mjs\">import { isStringOneByteRepresentation } from 'node:v8';\nimport { Buffer } from 'node:buffer';\n\nconst Encoding = {\n  latin1: 1,\n  utf16le: 2,\n};\nconst buffer = Buffer.alloc(100);\nfunction writeString(input) {\n  if (isStringOneByteRepresentation(input)) {\n    console.log(`input: '${input}'`);\n    buffer.writeUint8(Encoding.latin1);\n    buffer.writeUint32LE(input.length, 1);\n    buffer.write(input, 5, 'latin1');\n    console.log(`decoded: '${buffer.toString('latin1', 5, 5 + input.length)}'\\n`);\n  } else {\n    console.log(`input: '${input}'`);\n    buffer.writeUint8(Encoding.utf16le);\n    buffer.writeUint32LE(input.length * 2, 1);\n    buffer.write(input, 5, 'utf16le');\n    console.log(`decoded: '${buffer.toString('utf16le', 5, 5 + input.length * 2)}'`);\n  }\n}\nwriteString('hello');\nwriteString('你好');\n</code></pre>\n<pre><code class=\"language-cjs\">const { isStringOneByteRepresentation } = require('node:v8');\nconst { Buffer } = require('node:buffer');\n\nconst Encoding = {\n  latin1: 1,\n  utf16le: 2,\n};\nconst buffer = Buffer.alloc(100);\nfunction writeString(input) {\n  if (isStringOneByteRepresentation(input)) {\n    console.log(`input: '${input}'`);\n    buffer.writeUint8(Encoding.latin1);\n    buffer.writeUint32LE(input.length, 1);\n    buffer.write(input, 5, 'latin1');\n    console.log(`decoded: '${buffer.toString('latin1', 5, 5 + input.length)}'\\n`);\n  } else {\n    console.log(`input: '${input}'`);\n    buffer.writeUint8(Encoding.utf16le);\n    buffer.writeUint32LE(input.length * 2, 1);\n    buffer.write(input, 5, 'utf16le');\n    console.log(`decoded: '${buffer.toString('utf16le', 5, 5 + input.length * 2)}'`);\n  }\n}\nwriteString('hello');\nwriteString('你好');\n</code></pre>"
        },
        {
          "textRaw": "`v8.startCpuProfile([options])`",
          "name": "startCpuProfile",
          "type": "method",
          "meta": {
            "added": [
              "v25.0.0",
              "v24.12.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`sampleInterval` {number} Requested sampling interval in milliseconds. **Default:** `0`.",
                      "name": "sampleInterval",
                      "type": "number",
                      "default": "`0`",
                      "desc": "Requested sampling interval in milliseconds."
                    },
                    {
                      "textRaw": "`maxBufferSize` {integer} Maximum number of samples to keep before older entries are discarded. **Default:** `4294967295`.",
                      "name": "maxBufferSize",
                      "type": "integer",
                      "default": "`4294967295`",
                      "desc": "Maximum number of samples to keep before older entries are discarded."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {SyncCPUProfileHandle}",
                "name": "return",
                "type": "SyncCPUProfileHandle"
              }
            }
          ],
          "desc": "<p>Starting a CPU profile then return a <code>SyncCPUProfileHandle</code> object.\nThis API supports <code>using</code> syntax.</p>\n<pre><code class=\"language-cjs\">const handle = v8.startCpuProfile({ sampleInterval: 1, maxBufferSize: 10_000 });\nconst profile = handle.stop();\nconsole.log(profile);\n</code></pre>"
        },
        {
          "textRaw": "`v8.startHeapProfile([options])`",
          "name": "startHeapProfile",
          "type": "method",
          "meta": {
            "added": [
              "v26.1.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`options` {Object}",
                  "name": "options",
                  "type": "Object",
                  "options": [
                    {
                      "textRaw": "`sampleInterval` {number} The average sampling interval in bytes. **Default:** `524288` (512 KiB).",
                      "name": "sampleInterval",
                      "type": "number",
                      "default": "`524288` (512 KiB)",
                      "desc": "The average sampling interval in bytes."
                    },
                    {
                      "textRaw": "`stackDepth` {integer} The maximum stack depth for samples. **Default:** `16`.",
                      "name": "stackDepth",
                      "type": "integer",
                      "default": "`16`",
                      "desc": "The maximum stack depth for samples."
                    },
                    {
                      "textRaw": "`forceGC` {boolean} Force garbage collection before taking the profile. **Default:** `false`.",
                      "name": "forceGC",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Force garbage collection before taking the profile."
                    },
                    {
                      "textRaw": "`includeObjectsCollectedByMajorGC` {boolean} Include objects collected by major GC. **Default:** `false`.",
                      "name": "includeObjectsCollectedByMajorGC",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Include objects collected by major GC."
                    },
                    {
                      "textRaw": "`includeObjectsCollectedByMinorGC` {boolean} Include objects collected by minor GC. **Default:** `false`.",
                      "name": "includeObjectsCollectedByMinorGC",
                      "type": "boolean",
                      "default": "`false`",
                      "desc": "Include objects collected by minor GC."
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {SyncHeapProfileHandle}",
                "name": "return",
                "type": "SyncHeapProfileHandle"
              }
            }
          ],
          "desc": "<p>Starting a heap profile then return a <code>SyncHeapProfileHandle</code> object.\nThis API supports <code>using</code> syntax.</p>\n<pre><code class=\"language-cjs\">const v8 = require('node:v8');\n\nconst handle = v8.startHeapProfile();\nconst profile = handle.stop();\nconsole.log(profile);\n</code></pre>\n<pre><code class=\"language-mjs\">import v8 from 'node:v8';\n\nconst handle = v8.startHeapProfile();\nconst profile = handle.stop();\nconsole.log(profile);\n</code></pre>\n<p>With custom parameters:</p>\n<pre><code class=\"language-cjs\">const v8 = require('node:v8');\n\nconst handle = v8.startHeapProfile({\n  sampleInterval: 1024,\n  stackDepth: 8,\n  forceGC: true,\n  includeObjectsCollectedByMajorGC: true,\n});\nconst profile = handle.stop();\nconsole.log(profile);\n</code></pre>\n<pre><code class=\"language-mjs\">import v8 from 'node:v8';\n\nconst handle = v8.startHeapProfile({\n  sampleInterval: 1024,\n  stackDepth: 8,\n  forceGC: true,\n  includeObjectsCollectedByMajorGC: true,\n});\nconst profile = handle.stop();\nconsole.log(profile);\n</code></pre>"
        }
      ],
      "modules": [
        {
          "textRaw": "Serialization API",
          "name": "serialization_api",
          "type": "module",
          "desc": "<p>The serialization API provides means of serializing JavaScript values in a way\nthat is compatible with the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\">HTML structured clone algorithm</a>.</p>\n<p>The format is backward-compatible (i.e. safe to store to disk).\nEqual JavaScript values may result in different serialized output.</p>",
          "methods": [
            {
              "textRaw": "`v8.serialize(value)`",
              "name": "serialize",
              "type": "method",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`value` {any}",
                      "name": "value",
                      "type": "any"
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Buffer}",
                    "name": "return",
                    "type": "Buffer"
                  }
                }
              ],
              "desc": "<p>Uses a <a href=\"#class-v8defaultserializer\"><code>DefaultSerializer</code></a> to serialize <code>value</code> into a buffer.</p>\n<p><a href=\"errors.html#err_buffer_too_large\"><code>ERR_BUFFER_TOO_LARGE</code></a> will be thrown when trying to\nserialize a huge object which requires buffer\nlarger than <a href=\"buffer.html#bufferconstantsmax_length\"><code>buffer.constants.MAX_LENGTH</code></a>.</p>"
            },
            {
              "textRaw": "`v8.deserialize(buffer)`",
              "name": "deserialize",
              "type": "method",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`buffer` {Buffer|TypedArray|DataView} A buffer returned by `serialize()`.",
                      "name": "buffer",
                      "type": "Buffer|TypedArray|DataView",
                      "desc": "A buffer returned by `serialize()`."
                    }
                  ]
                }
              ],
              "desc": "<p>Uses a <a href=\"#class-v8defaultdeserializer\"><code>DefaultDeserializer</code></a> with default options to read a JS value\nfrom a buffer.</p>"
            }
          ],
          "classes": [
            {
              "textRaw": "Class: `v8.Serializer`",
              "name": "v8.Serializer",
              "type": "class",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "textRaw": "`new Serializer()`",
                  "name": "Serializer",
                  "type": "ctor",
                  "params": [],
                  "desc": "<p>Creates a new <code>Serializer</code> object.</p>"
                }
              ],
              "methods": [
                {
                  "textRaw": "`serializer.writeHeader()`",
                  "name": "writeHeader",
                  "type": "method",
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>Writes out a header, which includes the serialization format version.</p>"
                },
                {
                  "textRaw": "`serializer.writeValue(value)`",
                  "name": "writeValue",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`value` {any}",
                          "name": "value",
                          "type": "any"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Serializes a JavaScript value and adds the serialized representation to the\ninternal buffer.</p>\n<p>This throws an error if <code>value</code> cannot be serialized.</p>"
                },
                {
                  "textRaw": "`serializer.releaseBuffer()`",
                  "name": "releaseBuffer",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [],
                      "return": {
                        "textRaw": "Returns: {Buffer}",
                        "name": "return",
                        "type": "Buffer"
                      }
                    }
                  ],
                  "desc": "<p>Returns the stored internal buffer. This serializer should not be used once\nthe buffer is released. Calling this method results in undefined behavior\nif a previous write has failed.</p>"
                },
                {
                  "textRaw": "`serializer.transferArrayBuffer(id, arrayBuffer)`",
                  "name": "transferArrayBuffer",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`id` {integer} A 32-bit unsigned integer.",
                          "name": "id",
                          "type": "integer",
                          "desc": "A 32-bit unsigned integer."
                        },
                        {
                          "textRaw": "`arrayBuffer` {ArrayBuffer} An `ArrayBuffer` instance.",
                          "name": "arrayBuffer",
                          "type": "ArrayBuffer",
                          "desc": "An `ArrayBuffer` instance."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Marks an <code>ArrayBuffer</code> as having its contents transferred out of band.\nPass the corresponding <code>ArrayBuffer</code> in the deserializing context to\n<a href=\"#deserializertransferarraybufferid-arraybuffer\"><code>deserializer.transferArrayBuffer()</code></a>.</p>"
                },
                {
                  "textRaw": "`serializer.writeUint32(value)`",
                  "name": "writeUint32",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`value` {integer}",
                          "name": "value",
                          "type": "integer"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Write a raw 32-bit unsigned integer.\nFor use inside of a custom <a href=\"#serializer_writehostobjectobject\"><code>serializer._writeHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`serializer.writeUint64(hi, lo)`",
                  "name": "writeUint64",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`hi` {integer}",
                          "name": "hi",
                          "type": "integer"
                        },
                        {
                          "textRaw": "`lo` {integer}",
                          "name": "lo",
                          "type": "integer"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.\nFor use inside of a custom <a href=\"#serializer_writehostobjectobject\"><code>serializer._writeHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`serializer.writeDouble(value)`",
                  "name": "writeDouble",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`value` {number}",
                          "name": "value",
                          "type": "number"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Write a JS <code>number</code> value.\nFor use inside of a custom <a href=\"#serializer_writehostobjectobject\"><code>serializer._writeHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`serializer.writeRawBytes(buffer)`",
                  "name": "writeRawBytes",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`buffer` {Buffer|TypedArray|DataView}",
                          "name": "buffer",
                          "type": "Buffer|TypedArray|DataView"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Write raw bytes into the serializer's internal buffer. The deserializer\nwill require a way to compute the length of the buffer.\nFor use inside of a custom <a href=\"#serializer_writehostobjectobject\"><code>serializer._writeHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`serializer._writeHostObject(object)`",
                  "name": "_writeHostObject",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`object` {Object}",
                          "name": "object",
                          "type": "Object"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This method is called to write some kind of host object, i.e. an object created\nby native C++ bindings. If it is not possible to serialize <code>object</code>, a suitable\nexception should be thrown.</p>\n<p>This method is not present on the <code>Serializer</code> class itself but can be provided\nby subclasses.</p>"
                },
                {
                  "textRaw": "`serializer._getDataCloneError(message)`",
                  "name": "_getDataCloneError",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`message` {string}",
                          "name": "message",
                          "type": "string"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This method is called to generate error objects that will be thrown when an\nobject can not be cloned.</p>\n<p>This method defaults to the <a href=\"errors.html#class-error\"><code>Error</code></a> constructor and can be overridden on\nsubclasses.</p>"
                },
                {
                  "textRaw": "`serializer._getSharedArrayBufferId(sharedArrayBuffer)`",
                  "name": "_getSharedArrayBufferId",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`sharedArrayBuffer` {SharedArrayBuffer}",
                          "name": "sharedArrayBuffer",
                          "type": "SharedArrayBuffer"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>This method is called when the serializer is going to serialize a\n<code>SharedArrayBuffer</code> object. It must return an unsigned 32-bit integer ID for\nthe object, using the same ID if this <code>SharedArrayBuffer</code> has already been\nserialized. When deserializing, this ID will be passed to\n<a href=\"#deserializertransferarraybufferid-arraybuffer\"><code>deserializer.transferArrayBuffer()</code></a>.</p>\n<p>If the object cannot be serialized, an exception should be thrown.</p>\n<p>This method is not present on the <code>Serializer</code> class itself but can be provided\nby subclasses.</p>"
                },
                {
                  "textRaw": "`serializer._setTreatArrayBufferViewsAsHostObjects(flag)`",
                  "name": "_setTreatArrayBufferViewsAsHostObjects",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`flag` {boolean} **Default:** `false`",
                          "name": "flag",
                          "type": "boolean",
                          "default": "`false`"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Indicate whether to treat <code>TypedArray</code> and <code>DataView</code> objects as\nhost objects, i.e. pass them to <a href=\"#serializer_writehostobjectobject\"><code>serializer._writeHostObject()</code></a>.</p>"
                }
              ]
            },
            {
              "textRaw": "Class: `v8.Deserializer`",
              "name": "v8.Deserializer",
              "type": "class",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "textRaw": "`new Deserializer(buffer)`",
                  "name": "Deserializer",
                  "type": "ctor",
                  "params": [
                    {
                      "textRaw": "`buffer` {Buffer|TypedArray|DataView} A buffer returned by `serializer.releaseBuffer()`.",
                      "name": "buffer",
                      "type": "Buffer|TypedArray|DataView",
                      "desc": "A buffer returned by `serializer.releaseBuffer()`."
                    }
                  ],
                  "desc": "<p>Creates a new <code>Deserializer</code> object.</p>"
                }
              ],
              "methods": [
                {
                  "textRaw": "`deserializer.readHeader()`",
                  "name": "readHeader",
                  "type": "method",
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>Reads and validates a header (including the format version).\nMay, for example, reject an invalid or unsupported wire format. In that case,\nan <code>Error</code> is thrown.</p>"
                },
                {
                  "textRaw": "`deserializer.readValue()`",
                  "name": "readValue",
                  "type": "method",
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>Deserializes a JavaScript value from the buffer and returns it.</p>"
                },
                {
                  "textRaw": "`deserializer.transferArrayBuffer(id, arrayBuffer)`",
                  "name": "transferArrayBuffer",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`id` {integer} A 32-bit unsigned integer.",
                          "name": "id",
                          "type": "integer",
                          "desc": "A 32-bit unsigned integer."
                        },
                        {
                          "textRaw": "`arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An `ArrayBuffer` instance.",
                          "name": "arrayBuffer",
                          "type": "ArrayBuffer|SharedArrayBuffer",
                          "desc": "An `ArrayBuffer` instance."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Marks an <code>ArrayBuffer</code> as having its contents transferred out of band.\nPass the corresponding <code>ArrayBuffer</code> in the serializing context to\n<a href=\"#serializertransferarraybufferid-arraybuffer\"><code>serializer.transferArrayBuffer()</code></a> (or return the <code>id</code> from\n<a href=\"#serializer_getsharedarraybufferidsharedarraybuffer\"><code>serializer._getSharedArrayBufferId()</code></a> in the case of <code>SharedArrayBuffer</code>s).</p>"
                },
                {
                  "textRaw": "`deserializer.getWireFormatVersion()`",
                  "name": "getWireFormatVersion",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [],
                      "return": {
                        "textRaw": "Returns: {integer}",
                        "name": "return",
                        "type": "integer"
                      }
                    }
                  ],
                  "desc": "<p>Reads the underlying wire format version. Likely mostly to be useful to\nlegacy code reading old wire format versions. May not be called before\n<code>.readHeader()</code>.</p>"
                },
                {
                  "textRaw": "`deserializer.readUint32()`",
                  "name": "readUint32",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [],
                      "return": {
                        "textRaw": "Returns: {integer}",
                        "name": "return",
                        "type": "integer"
                      }
                    }
                  ],
                  "desc": "<p>Read a raw 32-bit unsigned integer and return it.\nFor use inside of a custom <a href=\"#deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`deserializer.readUint64()`",
                  "name": "readUint64",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [],
                      "return": {
                        "textRaw": "Returns: {integer[]}",
                        "name": "return",
                        "type": "integer[]"
                      }
                    }
                  ],
                  "desc": "<p>Read a raw 64-bit unsigned integer and return it as an array <code>[hi, lo]</code>\nwith two 32-bit unsigned integer entries.\nFor use inside of a custom <a href=\"#deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`deserializer.readDouble()`",
                  "name": "readDouble",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [],
                      "return": {
                        "textRaw": "Returns: {number}",
                        "name": "return",
                        "type": "number"
                      }
                    }
                  ],
                  "desc": "<p>Read a JS <code>number</code> value.\nFor use inside of a custom <a href=\"#deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`deserializer.readRawBytes(length)`",
                  "name": "readRawBytes",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`length` {integer}",
                          "name": "length",
                          "type": "integer"
                        }
                      ],
                      "return": {
                        "textRaw": "Returns: {Buffer}",
                        "name": "return",
                        "type": "Buffer"
                      }
                    }
                  ],
                  "desc": "<p>Read raw bytes from the deserializer's internal buffer. The <code>length</code> parameter\nmust correspond to the length of the buffer that was passed to\n<a href=\"#serializerwriterawbytesbuffer\"><code>serializer.writeRawBytes()</code></a>.\nFor use inside of a custom <a href=\"#deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
                },
                {
                  "textRaw": "`deserializer._readHostObject()`",
                  "name": "_readHostObject",
                  "type": "method",
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>This method is called to read some kind of host object, i.e. an object that is\ncreated by native C++ bindings. If it is not possible to deserialize the data,\na suitable exception should be thrown.</p>\n<p>This method is not present on the <code>Deserializer</code> class itself but can be\nprovided by subclasses.</p>"
                }
              ]
            },
            {
              "textRaw": "Class: `v8.DefaultSerializer`",
              "name": "v8.DefaultSerializer",
              "type": "class",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "desc": "<p>A subclass of <a href=\"#class-v8serializer\"><code>Serializer</code></a> that serializes <code>TypedArray</code>\n(in particular <a href=\"buffer.html\"><code>Buffer</code></a>) and <code>DataView</code> objects as host objects, and only\nstores the part of their underlying <code>ArrayBuffer</code>s that they are referring to.</p>"
            },
            {
              "textRaw": "Class: `v8.DefaultDeserializer`",
              "name": "v8.DefaultDeserializer",
              "type": "class",
              "meta": {
                "added": [
                  "v8.0.0"
                ],
                "changes": []
              },
              "desc": "<p>A subclass of <a href=\"#class-v8deserializer\"><code>Deserializer</code></a> corresponding to the format written by\n<a href=\"#class-v8defaultserializer\"><code>DefaultSerializer</code></a>.</p>"
            }
          ],
          "displayName": "Serialization API"
        },
        {
          "textRaw": "Promise hooks",
          "name": "promise_hooks",
          "type": "module",
          "desc": "<p>The <code>promiseHooks</code> interface can be used to track promise lifecycle events.\nTo track <em>all</em> async activity, see <a href=\"async_hooks.html\"><code>async_hooks</code></a> which internally uses this\nmodule to produce promise lifecycle events in addition to events for other\nasync resources. For request context management, see <a href=\"async_context.html#class-asynclocalstorage\"><code>AsyncLocalStorage</code></a>.</p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\n// There are four lifecycle events produced by promises:\n\n// The `init` event represents the creation of a promise. This could be a\n// direct creation such as with `new Promise(...)` or a continuation such\n// as `then()` or `catch()`. It also happens whenever an async function is\n// called or does an `await`. If a continuation promise is created, the\n// `parent` will be the promise it is a continuation from.\nfunction init(promise, parent) {\n  console.log('a promise was created', { promise, parent });\n}\n\n// The `settled` event happens when a promise receives a resolution or\n// rejection value. This may happen synchronously such as when using\n// `Promise.resolve()` on non-promise input.\nfunction settled(promise) {\n  console.log('a promise resolved or rejected', { promise });\n}\n\n// The `before` event runs immediately before a `then()` or `catch()` handler\n// runs or an `await` resumes execution.\nfunction before(promise) {\n  console.log('a promise is about to call a then handler', { promise });\n}\n\n// The `after` event runs immediately after a `then()` handler runs or when\n// an `await` begins after resuming from another.\nfunction after(promise) {\n  console.log('a promise is done calling a then handler', { promise });\n}\n\n// Lifecycle hooks may be started and stopped individually\nconst stopWatchingInits = promiseHooks.onInit(init);\nconst stopWatchingSettleds = promiseHooks.onSettled(settled);\nconst stopWatchingBefores = promiseHooks.onBefore(before);\nconst stopWatchingAfters = promiseHooks.onAfter(after);\n\n// Or they may be started and stopped in groups\nconst stopHookSet = promiseHooks.createHook({\n  init,\n  settled,\n  before,\n  after,\n});\n\n// Trigger the hooks by using promises\nconst promiseLog = (word) => Promise.resolve(word).then(console.log);\npromiseLog('Hello');\npromiseLog('World');\n\n// To stop a hook, call the function returned at its creation.\nstopWatchingInits();\nstopWatchingSettleds();\nstopWatchingBefores();\nstopWatchingAfters();\nstopHookSet();\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\n// There are four lifecycle events produced by promises:\n\n// The `init` event represents the creation of a promise. This could be a\n// direct creation such as with `new Promise(...)` or a continuation such\n// as `then()` or `catch()`. It also happens whenever an async function is\n// called or does an `await`. If a continuation promise is created, the\n// `parent` will be the promise it is a continuation from.\nfunction init(promise, parent) {\n  console.log('a promise was created', { promise, parent });\n}\n\n// The `settled` event happens when a promise receives a resolution or\n// rejection value. This may happen synchronously such as when using\n// `Promise.resolve()` on non-promise input.\nfunction settled(promise) {\n  console.log('a promise resolved or rejected', { promise });\n}\n\n// The `before` event runs immediately before a `then()` or `catch()` handler\n// runs or an `await` resumes execution.\nfunction before(promise) {\n  console.log('a promise is about to call a then handler', { promise });\n}\n\n// The `after` event runs immediately after a `then()` handler runs or when\n// an `await` begins after resuming from another.\nfunction after(promise) {\n  console.log('a promise is done calling a then handler', { promise });\n}\n\n// Lifecycle hooks may be started and stopped individually\nconst stopWatchingInits = promiseHooks.onInit(init);\nconst stopWatchingSettleds = promiseHooks.onSettled(settled);\nconst stopWatchingBefores = promiseHooks.onBefore(before);\nconst stopWatchingAfters = promiseHooks.onAfter(after);\n\n// Or they may be started and stopped in groups\nconst stopHookSet = promiseHooks.createHook({\n  init,\n  settled,\n  before,\n  after,\n});\n\n// Trigger the hooks by using promises\nconst promisePrint = (word) => Promise.resolve(word).then(console.log);\npromisePrint('Hello');\npromisePrint('World');\n\n// To stop a hook, call the function returned at its creation.\nstopWatchingInits();\nstopWatchingSettleds();\nstopWatchingBefores();\nstopWatchingAfters();\nstopHookSet();\n</code></pre>",
          "methods": [
            {
              "textRaw": "`promiseHooks.onInit(init)`",
              "name": "onInit",
              "type": "method",
              "meta": {
                "added": [
                  "v17.1.0",
                  "v16.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`init` {Function} The `init` callback to call when a promise is created.",
                      "name": "init",
                      "type": "Function",
                      "desc": "The `init` callback to call when a promise is created."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} Call to stop the hook.",
                    "name": "return",
                    "type": "Function",
                    "desc": "Call to stop the hook."
                  }
                }
              ],
              "desc": "<p><strong>The <code>init</code> hook must be a plain function. Providing an async function will\nthrow as it would produce an infinite microtask loop.</strong></p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\nconst stop = promiseHooks.onInit((promise, parent) => {});\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\nconst stop = promiseHooks.onInit((promise, parent) => {});\n</code></pre>"
            },
            {
              "textRaw": "`promiseHooks.onSettled(settled)`",
              "name": "onSettled",
              "type": "method",
              "meta": {
                "added": [
                  "v17.1.0",
                  "v16.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`settled` {Function} The `settled` callback to call when a promise is resolved or rejected.",
                      "name": "settled",
                      "type": "Function",
                      "desc": "The `settled` callback to call when a promise is resolved or rejected."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} Call to stop the hook.",
                    "name": "return",
                    "type": "Function",
                    "desc": "Call to stop the hook."
                  }
                }
              ],
              "desc": "<p><strong>The <code>settled</code> hook must be a plain function. Providing an async function will\nthrow as it would produce an infinite microtask loop.</strong></p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\nconst stop = promiseHooks.onSettled((promise) => {});\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\nconst stop = promiseHooks.onSettled((promise) => {});\n</code></pre>"
            },
            {
              "textRaw": "`promiseHooks.onBefore(before)`",
              "name": "onBefore",
              "type": "method",
              "meta": {
                "added": [
                  "v17.1.0",
                  "v16.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`before` {Function} The `before` callback to call before a promise continuation executes.",
                      "name": "before",
                      "type": "Function",
                      "desc": "The `before` callback to call before a promise continuation executes."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} Call to stop the hook.",
                    "name": "return",
                    "type": "Function",
                    "desc": "Call to stop the hook."
                  }
                }
              ],
              "desc": "<p><strong>The <code>before</code> hook must be a plain function. Providing an async function will\nthrow as it would produce an infinite microtask loop.</strong></p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\nconst stop = promiseHooks.onBefore((promise) => {});\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\nconst stop = promiseHooks.onBefore((promise) => {});\n</code></pre>"
            },
            {
              "textRaw": "`promiseHooks.onAfter(after)`",
              "name": "onAfter",
              "type": "method",
              "meta": {
                "added": [
                  "v17.1.0",
                  "v16.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`after` {Function} The `after` callback to call after a promise continuation executes.",
                      "name": "after",
                      "type": "Function",
                      "desc": "The `after` callback to call after a promise continuation executes."
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} Call to stop the hook.",
                    "name": "return",
                    "type": "Function",
                    "desc": "Call to stop the hook."
                  }
                }
              ],
              "desc": "<p><strong>The <code>after</code> hook must be a plain function. Providing an async function will\nthrow as it would produce an infinite microtask loop.</strong></p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\nconst stop = promiseHooks.onAfter((promise) => {});\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\nconst stop = promiseHooks.onAfter((promise) => {});\n</code></pre>"
            },
            {
              "textRaw": "`promiseHooks.createHook(callbacks)`",
              "name": "createHook",
              "type": "method",
              "meta": {
                "added": [
                  "v17.1.0",
                  "v16.14.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callbacks` {Object} The Hook Callbacks to register",
                      "name": "callbacks",
                      "type": "Object",
                      "desc": "The Hook Callbacks to register",
                      "options": [
                        {
                          "textRaw": "`init` {Function} The `init` callback.",
                          "name": "init",
                          "type": "Function",
                          "desc": "The `init` callback."
                        },
                        {
                          "textRaw": "`before` {Function} The `before` callback.",
                          "name": "before",
                          "type": "Function",
                          "desc": "The `before` callback."
                        },
                        {
                          "textRaw": "`after` {Function} The `after` callback.",
                          "name": "after",
                          "type": "Function",
                          "desc": "The `after` callback."
                        },
                        {
                          "textRaw": "`settled` {Function} The `settled` callback.",
                          "name": "settled",
                          "type": "Function",
                          "desc": "The `settled` callback."
                        }
                      ]
                    }
                  ],
                  "return": {
                    "textRaw": "Returns: {Function} Used for disabling hooks",
                    "name": "return",
                    "type": "Function",
                    "desc": "Used for disabling hooks"
                  }
                }
              ],
              "desc": "<p><strong>The hook callbacks must be plain functions. Providing async functions will\nthrow as it would produce an infinite microtask loop.</strong></p>\n<p>Registers functions to be called for different lifetime events of each promise.</p>\n<p>The callbacks <code>init()</code>/<code>before()</code>/<code>after()</code>/<code>settled()</code> are called for the\nrespective events during a promise's lifetime.</p>\n<p>All callbacks are optional. For example, if only promise creation needs to\nbe tracked, then only the <code>init</code> callback needs to be passed. The\nspecifics of all functions that can be passed to <code>callbacks</code> is in the\n<a href=\"#hook-callbacks\">Hook Callbacks</a> section.</p>\n<pre><code class=\"language-mjs\">import { promiseHooks } from 'node:v8';\n\nconst stopAll = promiseHooks.createHook({\n  init(promise, parent) {},\n});\n</code></pre>\n<pre><code class=\"language-cjs\">const { promiseHooks } = require('node:v8');\n\nconst stopAll = promiseHooks.createHook({\n  init(promise, parent) {},\n});\n</code></pre>"
            }
          ],
          "modules": [
            {
              "textRaw": "Hook callbacks",
              "name": "hook_callbacks",
              "type": "module",
              "desc": "<p>Key events in the lifetime of a promise have been categorized into four areas:\ncreation of a promise, before/after a continuation handler is called or around\nan await, and when the promise resolves or rejects.</p>\n<p>While these hooks are similar to those of <a href=\"async_hooks.html\"><code>async_hooks</code></a> they lack a\n<code>destroy</code> hook. Other types of async resources typically represent sockets or\nfile descriptors which have a distinct \"closed\" state to express the <code>destroy</code>\nlifecycle event while promises remain usable for as long as code can still\nreach them. Garbage collection tracking is used to make promises fit into the\n<code>async_hooks</code> event model, however this tracking is very expensive and they may\nnot necessarily ever even be garbage collected.</p>\n<p>Because promises are asynchronous resources whose lifecycle is tracked\nvia the promise hooks mechanism, the <code>init()</code>, <code>before()</code>, <code>after()</code>, and\n<code>settled()</code> callbacks <em>must not</em> be async functions as they create more\npromises which would produce an infinite loop.</p>\n<p>While this API is used to feed promise events into <a href=\"async_hooks.html\"><code>async_hooks</code></a>, the\nordering between the two is undefined. Both APIs are multi-tenant\nand therefore could produce events in any order relative to each other.</p>",
              "methods": [
                {
                  "textRaw": "`init(promise, parent)`",
                  "name": "init",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`promise` {Promise} The promise being created.",
                          "name": "promise",
                          "type": "Promise",
                          "desc": "The promise being created."
                        },
                        {
                          "textRaw": "`parent` {Promise} The promise continued from, if applicable.",
                          "name": "parent",
                          "type": "Promise",
                          "desc": "The promise continued from, if applicable."
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Called when a promise is constructed. This <em>does not</em> mean that corresponding\n<code>before</code>/<code>after</code> events will occur, only that the possibility exists. This will\nhappen if a promise is created without ever getting a continuation.</p>"
                },
                {
                  "textRaw": "`before(promise)`",
                  "name": "before",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`promise` {Promise}",
                          "name": "promise",
                          "type": "Promise"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Called before a promise continuation executes. This can be in the form of\n<code>then()</code>, <code>catch()</code>, or <code>finally()</code> handlers or an <code>await</code> resuming.</p>\n<p>The <code>before</code> callback will be called 0 to N times. The <code>before</code> callback\nwill typically be called 0 times if no continuation was ever made for the\npromise. The <code>before</code> callback may be called many times in the case where\nmany continuations have been made from the same promise.</p>"
                },
                {
                  "textRaw": "`after(promise)`",
                  "name": "after",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`promise` {Promise}",
                          "name": "promise",
                          "type": "Promise"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Called immediately after a promise continuation executes. This may be after a\n<code>then()</code>, <code>catch()</code>, or <code>finally()</code> handler or before an <code>await</code> after another\n<code>await</code>.</p>"
                },
                {
                  "textRaw": "`settled(promise)`",
                  "name": "settled",
                  "type": "method",
                  "signatures": [
                    {
                      "params": [
                        {
                          "textRaw": "`promise` {Promise}",
                          "name": "promise",
                          "type": "Promise"
                        }
                      ]
                    }
                  ],
                  "desc": "<p>Called when the promise receives a resolution or rejection value. This may\noccur synchronously in the case of <code>Promise.resolve()</code> or <code>Promise.reject()</code>.</p>"
                }
              ],
              "displayName": "Hook callbacks"
            }
          ],
          "displayName": "Promise hooks"
        },
        {
          "textRaw": "Startup Snapshot API",
          "name": "startup_snapshot_api",
          "type": "module",
          "meta": {
            "added": [
              "v18.6.0",
              "v16.17.0"
            ],
            "changes": [
              {
                "version": [
                  "v24.0.0",
                  "v22.17.0"
                ],
                "pr-url": "https://github.com/nodejs/node/pull/57513",
                "description": "Marking the API stable."
              }
            ]
          },
          "desc": "<p>The <code>v8.startupSnapshot</code> interface can be used to add serialization and\ndeserialization hooks for custom startup snapshots.</p>\n<pre><code class=\"language-console\">$ node --snapshot-blob snapshot.blob --build-snapshot entry.js\n# This launches a process with the snapshot\n$ node --snapshot-blob snapshot.blob\n</code></pre>\n<p>In the example above, <code>entry.js</code> can use methods from the <code>v8.startupSnapshot</code>\ninterface to specify how to save information for custom objects in the snapshot\nduring serialization and how the information can be used to synchronize these\nobjects during deserialization of the snapshot. For example, if the <code>entry.js</code>\ncontains the following script:</p>\n<pre><code class=\"language-cjs\">const fs = require('node:fs');\nconst zlib = require('node:zlib');\nconst path = require('node:path');\nconst assert = require('node:assert');\n\nconst v8 = require('node:v8');\n\nclass BookShelf {\n  storage = new Map();\n\n  // Reading a series of files from directory and store them into storage.\n  constructor(directory, books) {\n    for (const book of books) {\n      this.storage.set(book, fs.readFileSync(path.join(directory, book)));\n    }\n  }\n\n  static compressAll(shelf) {\n    for (const [ book, content ] of shelf.storage) {\n      shelf.storage.set(book, zlib.gzipSync(content));\n    }\n  }\n\n  static decompressAll(shelf) {\n    for (const [ book, content ] of shelf.storage) {\n      shelf.storage.set(book, zlib.gunzipSync(content));\n    }\n  }\n}\n\n// __dirname here is where the snapshot script is placed\n// during snapshot building time.\nconst shelf = new BookShelf(__dirname, [\n  'book1.en_US.txt',\n  'book1.es_ES.txt',\n  'book2.zh_CN.txt',\n]);\n\nassert(v8.startupSnapshot.isBuildingSnapshot());\n// On snapshot serialization, compress the books to reduce size.\nv8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);\n// On snapshot deserialization, decompress the books.\nv8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);\nv8.startupSnapshot.setDeserializeMainFunction((shelf) => {\n  // process.env and process.argv are refreshed during snapshot\n  // deserialization.\n  const lang = process.env.BOOK_LANG || 'en_US';\n  const book = process.argv[1];\n  const name = `${book}.${lang}.txt`;\n  console.log(shelf.storage.get(name));\n}, shelf);\n</code></pre>\n<p>The resulted binary will get print the data deserialized from the snapshot\nduring start up, using the refreshed <code>process.env</code> and <code>process.argv</code> of\nthe launched process:</p>\n<pre><code class=\"language-console\">$ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1\n# Prints content of book1.es_ES.txt deserialized from the snapshot.\n</code></pre>\n<p>Currently the application deserialized from a user-land snapshot cannot\nbe snapshotted again, so these APIs are only available to applications\nthat are not deserialized from a user-land snapshot.</p>",
          "methods": [
            {
              "textRaw": "`v8.startupSnapshot.addSerializeCallback(callback[, data])`",
              "name": "addSerializeCallback",
              "type": "method",
              "meta": {
                "added": [
                  "v18.6.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function} Callback to be invoked before serialization.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Callback to be invoked before serialization."
                    },
                    {
                      "textRaw": "`data` {any} Optional data that will be passed to the `callback` when it gets called.",
                      "name": "data",
                      "type": "any",
                      "desc": "Optional data that will be passed to the `callback` when it gets called.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Add a callback that will be called when the Node.js instance is about to\nget serialized into a snapshot and exit. This can be used to release\nresources that should not or cannot be serialized or to convert user data\ninto a form more suitable for serialization.</p>\n<p>Callbacks are run in the order in which they are added.</p>"
            },
            {
              "textRaw": "`v8.startupSnapshot.addDeserializeCallback(callback[, data])`",
              "name": "addDeserializeCallback",
              "type": "method",
              "meta": {
                "added": [
                  "v18.6.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function} Callback to be invoked after the snapshot is deserialized.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Callback to be invoked after the snapshot is deserialized."
                    },
                    {
                      "textRaw": "`data` {any} Optional data that will be passed to the `callback` when it gets called.",
                      "name": "data",
                      "type": "any",
                      "desc": "Optional data that will be passed to the `callback` when it gets called.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>Add a callback that will be called when the Node.js instance is deserialized\nfrom a snapshot. The <code>callback</code> and the <code>data</code> (if provided) will be\nserialized into the snapshot, they can be used to re-initialize the state\nof the application or to re-acquire resources that the application needs\nwhen the application is restarted from the snapshot.</p>\n<p>Callbacks are run in the order in which they are added.</p>"
            },
            {
              "textRaw": "`v8.startupSnapshot.setDeserializeMainFunction(callback[, data])`",
              "name": "setDeserializeMainFunction",
              "type": "method",
              "meta": {
                "added": [
                  "v18.6.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`callback` {Function} Callback to be invoked as the entry point after the snapshot is deserialized.",
                      "name": "callback",
                      "type": "Function",
                      "desc": "Callback to be invoked as the entry point after the snapshot is deserialized."
                    },
                    {
                      "textRaw": "`data` {any} Optional data that will be passed to the `callback` when it gets called.",
                      "name": "data",
                      "type": "any",
                      "desc": "Optional data that will be passed to the `callback` when it gets called.",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>This sets the entry point of the Node.js application when it is deserialized\nfrom a snapshot. This can be called only once in the snapshot building\nscript. If called, the deserialized application no longer needs an additional\nentry point script to start up and will simply invoke the callback along with\nthe deserialized data (if provided), otherwise an entry point script still\nneeds to be provided to the deserialized application.</p>"
            },
            {
              "textRaw": "`v8.startupSnapshot.isBuildingSnapshot()`",
              "name": "isBuildingSnapshot",
              "type": "method",
              "meta": {
                "added": [
                  "v18.6.0",
                  "v16.17.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {boolean}",
                    "name": "return",
                    "type": "boolean"
                  }
                }
              ],
              "desc": "<p>Returns true if the Node.js instance is run to build a snapshot.</p>"
            }
          ],
          "displayName": "Startup Snapshot API"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `v8.GCProfiler`",
          "name": "v8.GCProfiler",
          "type": "class",
          "meta": {
            "added": [
              "v19.6.0",
              "v18.15.0"
            ],
            "changes": []
          },
          "desc": "<p>This API collects GC data in current thread.</p>",
          "signatures": [
            {
              "textRaw": "`new v8.GCProfiler()`",
              "name": "v8.GCProfiler",
              "type": "ctor",
              "meta": {
                "added": [
                  "v19.6.0",
                  "v18.15.0"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>Create a new instance of the <code>v8.GCProfiler</code> class.\nThis API supports <code>using</code> syntax.</p>"
            }
          ],
          "methods": [
            {
              "textRaw": "`profiler.start()`",
              "name": "start",
              "type": "method",
              "meta": {
                "added": [
                  "v19.6.0",
                  "v18.15.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Start collecting GC data.</p>"
            },
            {
              "textRaw": "`profiler.stop()`",
              "name": "stop",
              "type": "method",
              "meta": {
                "added": [
                  "v19.6.0",
                  "v18.15.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Stop collecting GC data and return an object. The content of object\nis as follows.</p>\n<pre><code class=\"language-json\">{\n  \"version\": 1,\n  \"startTime\": 1674059033862,\n  \"statistics\": [\n    {\n      \"gcType\": \"Scavenge\",\n      \"beforeGC\": {\n        \"heapStatistics\": {\n          \"totalHeapSize\": 5005312,\n          \"totalHeapSizeExecutable\": 524288,\n          \"totalPhysicalSize\": 5226496,\n          \"totalAvailableSize\": 4341325216,\n          \"totalGlobalHandlesSize\": 8192,\n          \"usedGlobalHandlesSize\": 2112,\n          \"usedHeapSize\": 4883840,\n          \"heapSizeLimit\": 4345298944,\n          \"mallocedMemory\": 254128,\n          \"externalMemory\": 225138,\n          \"peakMallocedMemory\": 181760\n        },\n        \"heapSpaceStatistics\": [\n          {\n            \"spaceName\": \"read_only_space\",\n            \"spaceSize\": 0,\n            \"spaceUsedSize\": 0,\n            \"spaceAvailableSize\": 0,\n            \"physicalSpaceSize\": 0\n          }\n        ]\n      },\n      \"cost\": 1574.14,\n      \"afterGC\": {\n        \"heapStatistics\": {\n          \"totalHeapSize\": 6053888,\n          \"totalHeapSizeExecutable\": 524288,\n          \"totalPhysicalSize\": 5500928,\n          \"totalAvailableSize\": 4341101384,\n          \"totalGlobalHandlesSize\": 8192,\n          \"usedGlobalHandlesSize\": 2112,\n          \"usedHeapSize\": 4059096,\n          \"heapSizeLimit\": 4345298944,\n          \"mallocedMemory\": 254128,\n          \"externalMemory\": 225138,\n          \"peakMallocedMemory\": 181760\n        },\n        \"heapSpaceStatistics\": [\n          {\n            \"spaceName\": \"read_only_space\",\n            \"spaceSize\": 0,\n            \"spaceUsedSize\": 0,\n            \"spaceAvailableSize\": 0,\n            \"physicalSpaceSize\": 0\n          }\n        ]\n      }\n    }\n  ],\n  \"endTime\": 1674059036865\n}\n</code></pre>\n<p>Here's an example.</p>\n<pre><code class=\"language-mjs\">import { GCProfiler } from 'node:v8';\nconst profiler = new GCProfiler();\nprofiler.start();\nsetTimeout(() => {\n  console.log(profiler.stop());\n}, 1000);\n</code></pre>\n<pre><code class=\"language-cjs\">const { GCProfiler } = require('node:v8');\nconst profiler = new GCProfiler();\nprofiler.start();\nsetTimeout(() => {\n  console.log(profiler.stop());\n}, 1000);\n</code></pre>"
            },
            {
              "textRaw": "`profiler[Symbol.dispose]()`",
              "name": "[Symbol.dispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v25.5.0",
                  "v24.13.1"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Stop collecting GC data, and discard the profile.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `SyncCPUProfileHandle`",
          "name": "SyncCPUProfileHandle",
          "type": "class",
          "meta": {
            "added": [
              "v25.0.0",
              "v24.12.0"
            ],
            "changes": []
          },
          "methods": [
            {
              "textRaw": "`syncCpuProfileHandle.stop()`",
              "name": "stop",
              "type": "method",
              "meta": {
                "added": [
                  "v25.0.0",
                  "v24.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {string}",
                    "name": "return",
                    "type": "string"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile and return the profile data.</p>"
            },
            {
              "textRaw": "`syncCpuProfileHandle[Symbol.dispose]()`",
              "name": "[Symbol.dispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v25.0.0",
                  "v24.12.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Stopping collecting the profile and the profile will be discarded.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `SyncHeapProfileHandle`",
          "name": "SyncHeapProfileHandle",
          "type": "class",
          "meta": {
            "added": [
              "v26.1.0"
            ],
            "changes": []
          },
          "stability": 1,
          "stabilityText": "Experimental",
          "methods": [
            {
              "textRaw": "`syncHeapProfileHandle.stop()`",
              "name": "stop",
              "type": "method",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {string}",
                    "name": "return",
                    "type": "string"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile and return the profile data.</p>"
            },
            {
              "textRaw": "`syncHeapProfileHandle[Symbol.dispose]()`",
              "name": "[Symbol.dispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v26.1.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Stopping collecting the profile and the profile will be discarded.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `CPUProfileHandle`",
          "name": "CPUProfileHandle",
          "type": "class",
          "meta": {
            "added": [
              "v24.8.0"
            ],
            "changes": []
          },
          "methods": [
            {
              "textRaw": "`cpuProfileHandle.stop()`",
              "name": "stop",
              "type": "method",
              "meta": {
                "added": [
                  "v24.8.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Promise}",
                    "name": "return",
                    "type": "Promise"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile, then return a Promise that fulfills with an error or the\nprofile data.</p>"
            },
            {
              "textRaw": "`cpuProfileHandle[Symbol.asyncDispose]()`",
              "name": "[Symbol.asyncDispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v24.8.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Promise}",
                    "name": "return",
                    "type": "Promise"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile and the profile will be discarded.</p>"
            }
          ]
        },
        {
          "textRaw": "Class: `HeapProfileHandle`",
          "name": "HeapProfileHandle",
          "type": "class",
          "meta": {
            "added": [
              "v24.9.0"
            ],
            "changes": []
          },
          "methods": [
            {
              "textRaw": "`heapProfileHandle.stop()`",
              "name": "stop",
              "type": "method",
              "meta": {
                "added": [
                  "v24.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Promise}",
                    "name": "return",
                    "type": "Promise"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile, then return a Promise that fulfills with an error or the\nprofile data.</p>"
            },
            {
              "textRaw": "`heapProfileHandle[Symbol.asyncDispose]()`",
              "name": "[Symbol.asyncDispose]",
              "type": "method",
              "meta": {
                "added": [
                  "v24.9.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [],
                  "return": {
                    "textRaw": "Returns: {Promise}",
                    "name": "return",
                    "type": "Promise"
                  }
                }
              ],
              "desc": "<p>Stopping collecting the profile and the profile will be discarded.</p>"
            }
          ]
        }
      ],
      "displayName": "V8"
    }
  ]
}