• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2  "type": "module",
3  "source": "doc/api/v8.md",
4  "modules": [
5    {
6      "textRaw": "V8",
7      "name": "v8",
8      "introduced_in": "v4.0.0",
9      "desc": "<p><strong>Source Code:</strong> <a href=\"https://github.com/nodejs/node/blob/v14.20.1/lib/v8.js\">lib/v8.js</a></p>\n<p>The <code>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-js\">const v8 = require('v8');\n</code></pre>",
10      "methods": [
11        {
12          "textRaw": "`v8.cachedDataVersionTag()`",
13          "type": "method",
14          "name": "cachedDataVersionTag",
15          "meta": {
16            "added": [
17              "v8.0.0"
18            ],
19            "changes": []
20          },
21          "signatures": [
22            {
23              "return": {
24                "textRaw": "Returns: {integer}",
25                "name": "return",
26                "type": "integer"
27              },
28              "params": []
29            }
30          ],
31          "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#vm_new_vm_script_code_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>"
32        },
33        {
34          "textRaw": "`v8.getHeapCodeStatistics()`",
35          "type": "method",
36          "name": "getHeapCodeStatistics",
37          "meta": {
38            "added": [
39              "v12.8.0"
40            ],
41            "changes": []
42          },
43          "signatures": [
44            {
45              "return": {
46                "textRaw": "Returns: {Object}",
47                "name": "return",
48                "type": "Object"
49              },
50              "params": []
51            }
52          ],
53          "desc": "<p>Returns an object with the following properties:</p>\n<ul>\n<li><code>code_and_metadata_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>bytecode_and_metadata_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>external_script_source_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n</ul>\n<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\n  code_and_metadata_size: 212208,\n  bytecode_and_metadata_size: 161368,\n  external_script_source_size: 1410794\n}\n</code></pre>"
54        },
55        {
56          "textRaw": "`v8.getHeapSnapshot()`",
57          "type": "method",
58          "name": "getHeapSnapshot",
59          "meta": {
60            "added": [
61              "v11.13.0"
62            ],
63            "changes": []
64          },
65          "signatures": [
66            {
67              "return": {
68                "textRaw": "Returns: {stream.Readable} A Readable Stream containing the V8 heap snapshot",
69                "name": "return",
70                "type": "stream.Readable",
71                "desc": "A Readable Stream containing the V8 heap snapshot"
72              },
73              "params": []
74            }
75          ],
76          "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<pre><code class=\"language-js\">// Print heap snapshot to the console\nconst v8 = require('v8');\nconst stream = v8.getHeapSnapshot();\nstream.pipe(process.stdout);\n</code></pre>"
77        },
78        {
79          "textRaw": "`v8.getHeapSpaceStatistics()`",
80          "type": "method",
81          "name": "getHeapSpaceStatistics",
82          "meta": {
83            "added": [
84              "v6.0.0"
85            ],
86            "changes": [
87              {
88                "version": "v7.5.0",
89                "pr-url": "https://github.com/nodejs/node/pull/10186",
90                "description": "Support values exceeding the 32-bit unsigned integer range."
91              }
92            ]
93          },
94          "signatures": [
95            {
96              "return": {
97                "textRaw": "Returns: {Object[]}",
98                "name": "return",
99                "type": "Object[]"
100              },
101              "params": []
102            }
103          ],
104          "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/en-US/docs/Web/JavaScript/Data_structures#String_type\" class=\"type\">&lt;string&gt;</a></li>\n<li><code>space_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>space_used_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>space_available_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>physical_space_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</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>"
105        },
106        {
107          "textRaw": "`v8.getHeapStatistics()`",
108          "type": "method",
109          "name": "getHeapStatistics",
110          "meta": {
111            "added": [
112              "v1.0.0"
113            ],
114            "changes": [
115              {
116                "version": "v7.5.0",
117                "pr-url": "https://github.com/nodejs/node/pull/10186",
118                "description": "Support values exceeding the 32-bit unsigned integer range."
119              },
120              {
121                "version": "v7.2.0",
122                "pr-url": "https://github.com/nodejs/node/pull/8610",
123                "description": "Added `malloced_memory`, `peak_malloced_memory`, and `does_zap_garbage`."
124              }
125            ]
126          },
127          "signatures": [
128            {
129              "return": {
130                "textRaw": "Returns: {Object}",
131                "name": "return",
132                "type": "Object"
133              },
134              "params": []
135            }
136          ],
137          "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/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>total_heap_size_executable</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>total_physical_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>total_available_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>used_heap_size</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>heap_size_limit</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>malloced_memory</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>peak_malloced_memory</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>does_zap_garbage</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>number_of_native_contexts</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n<li><code>number_of_detached_contexts</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\" class=\"type\">&lt;number&gt;</a></li>\n</ul>\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<!-- eslint-skip -->\n<pre><code class=\"language-js\">{\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}\n</code></pre>"
138        },
139        {
140          "textRaw": "`v8.setFlagsFromString(flags)`",
141          "type": "method",
142          "name": "setFlagsFromString",
143          "meta": {
144            "added": [
145              "v1.0.0"
146            ],
147            "changes": []
148          },
149          "signatures": [
150            {
151              "params": [
152                {
153                  "textRaw": "`flags` {string}",
154                  "name": "flags",
155                  "type": "string"
156                }
157              ]
158            }
159          ],
160          "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-js\">// Print GC events to stdout for one minute.\nconst v8 = require('v8');\nv8.setFlagsFromString('--trace_gc');\nsetTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);\n</code></pre>"
161        },
162        {
163          "textRaw": "`v8.stopCoverage()`",
164          "type": "method",
165          "name": "stopCoverage",
166          "meta": {
167            "added": [
168              "v14.18.0"
169            ],
170            "changes": []
171          },
172          "signatures": [
173            {
174              "params": []
175            }
176          ],
177          "desc": "<p>The <code>v8.stopCoverage()</code> method allows the user to stop the coverage collection\nstarted by <a href=\"cli.html#cli_node_v8_coverage_dir\"><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=\"#v8_v8_takecoverage\"><code>v8.takeCoverage()</code></a> if the user wants to collect the coverage on demand.</p>"
178        },
179        {
180          "textRaw": "`v8.takeCoverage()`",
181          "type": "method",
182          "name": "takeCoverage",
183          "meta": {
184            "added": [
185              "v14.18.0"
186            ],
187            "changes": []
188          },
189          "signatures": [
190            {
191              "params": []
192            }
193          ],
194          "desc": "<p>The <code>v8.takeCoverage()</code> method allows the user to write the coverage started by\n<a href=\"cli.html#cli_node_v8_coverage_dir\"><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#cli_node_v8_coverage_dir\"><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=\"#v8_v8_stopcoverage\"><code>v8.stopCoverage()</code></a> is invoked before the process exits.</p>"
195        },
196        {
197          "textRaw": "`v8.writeHeapSnapshot([filename])`",
198          "type": "method",
199          "name": "writeHeapSnapshot",
200          "meta": {
201            "added": [
202              "v11.13.0"
203            ],
204            "changes": []
205          },
206          "signatures": [
207            {
208              "return": {
209                "textRaw": "Returns: {string} The filename where the snapshot was saved.",
210                "name": "return",
211                "type": "string",
212                "desc": "The filename where the snapshot was saved."
213              },
214              "params": [
215                {
216                  "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.",
217                  "name": "filename",
218                  "type": "string",
219                  "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."
220                }
221              ]
222            }
223          ],
224          "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<pre><code class=\"language-js\">const { writeHeapSnapshot } = require('v8');\nconst {\n  Worker,\n  isMainThread,\n  parentPort\n} = require('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>"
225        }
226      ],
227      "modules": [
228        {
229          "textRaw": "Serialization API",
230          "name": "serialization_api",
231          "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>",
232          "methods": [
233            {
234              "textRaw": "`v8.serialize(value)`",
235              "type": "method",
236              "name": "serialize",
237              "meta": {
238                "added": [
239                  "v8.0.0"
240                ],
241                "changes": []
242              },
243              "signatures": [
244                {
245                  "return": {
246                    "textRaw": "Returns: {Buffer}",
247                    "name": "return",
248                    "type": "Buffer"
249                  },
250                  "params": [
251                    {
252                      "textRaw": "`value` {any}",
253                      "name": "value",
254                      "type": "any"
255                    }
256                  ]
257                }
258              ],
259              "desc": "<p>Uses a <a href=\"#v8_class_v8_defaultserializer\"><code>DefaultSerializer</code></a> to serialize <code>value</code> into a buffer.</p>"
260            },
261            {
262              "textRaw": "`v8.deserialize(buffer)`",
263              "type": "method",
264              "name": "deserialize",
265              "meta": {
266                "added": [
267                  "v8.0.0"
268                ],
269                "changes": []
270              },
271              "signatures": [
272                {
273                  "params": [
274                    {
275                      "textRaw": "`buffer` {Buffer|TypedArray|DataView} A buffer returned by [`serialize()`][].",
276                      "name": "buffer",
277                      "type": "Buffer|TypedArray|DataView",
278                      "desc": "A buffer returned by [`serialize()`][]."
279                    }
280                  ]
281                }
282              ],
283              "desc": "<p>Uses a <a href=\"#v8_class_v8_defaultdeserializer\"><code>DefaultDeserializer</code></a> with default options to read a JS value\nfrom a buffer.</p>"
284            }
285          ],
286          "classes": [
287            {
288              "textRaw": "Class: `v8.Serializer`",
289              "type": "class",
290              "name": "v8.Serializer",
291              "meta": {
292                "added": [
293                  "v8.0.0"
294                ],
295                "changes": []
296              },
297              "methods": [
298                {
299                  "textRaw": "`serializer.writeHeader()`",
300                  "type": "method",
301                  "name": "writeHeader",
302                  "signatures": [
303                    {
304                      "params": []
305                    }
306                  ],
307                  "desc": "<p>Writes out a header, which includes the serialization format version.</p>"
308                },
309                {
310                  "textRaw": "`serializer.writeValue(value)`",
311                  "type": "method",
312                  "name": "writeValue",
313                  "signatures": [
314                    {
315                      "params": [
316                        {
317                          "textRaw": "`value` {any}",
318                          "name": "value",
319                          "type": "any"
320                        }
321                      ]
322                    }
323                  ],
324                  "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>"
325                },
326                {
327                  "textRaw": "`serializer.releaseBuffer()`",
328                  "type": "method",
329                  "name": "releaseBuffer",
330                  "signatures": [
331                    {
332                      "return": {
333                        "textRaw": "Returns: {Buffer}",
334                        "name": "return",
335                        "type": "Buffer"
336                      },
337                      "params": []
338                    }
339                  ],
340                  "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>"
341                },
342                {
343                  "textRaw": "`serializer.transferArrayBuffer(id, arrayBuffer)`",
344                  "type": "method",
345                  "name": "transferArrayBuffer",
346                  "signatures": [
347                    {
348                      "params": [
349                        {
350                          "textRaw": "`id` {integer} A 32-bit unsigned integer.",
351                          "name": "id",
352                          "type": "integer",
353                          "desc": "A 32-bit unsigned integer."
354                        },
355                        {
356                          "textRaw": "`arrayBuffer` {ArrayBuffer} An `ArrayBuffer` instance.",
357                          "name": "arrayBuffer",
358                          "type": "ArrayBuffer",
359                          "desc": "An `ArrayBuffer` instance."
360                        }
361                      ]
362                    }
363                  ],
364                  "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=\"#v8_deserializer_transferarraybuffer_id_arraybuffer\"><code>deserializer.transferArrayBuffer()</code></a>.</p>"
365                },
366                {
367                  "textRaw": "`serializer.writeUint32(value)`",
368                  "type": "method",
369                  "name": "writeUint32",
370                  "signatures": [
371                    {
372                      "params": [
373                        {
374                          "textRaw": "`value` {integer}",
375                          "name": "value",
376                          "type": "integer"
377                        }
378                      ]
379                    }
380                  ],
381                  "desc": "<p>Write a raw 32-bit unsigned integer.\nFor use inside of a custom <a href=\"#v8_serializer_writehostobject_object\"><code>serializer._writeHostObject()</code></a>.</p>"
382                },
383                {
384                  "textRaw": "`serializer.writeUint64(hi, lo)`",
385                  "type": "method",
386                  "name": "writeUint64",
387                  "signatures": [
388                    {
389                      "params": [
390                        {
391                          "textRaw": "`hi` {integer}",
392                          "name": "hi",
393                          "type": "integer"
394                        },
395                        {
396                          "textRaw": "`lo` {integer}",
397                          "name": "lo",
398                          "type": "integer"
399                        }
400                      ]
401                    }
402                  ],
403                  "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=\"#v8_serializer_writehostobject_object\"><code>serializer._writeHostObject()</code></a>.</p>"
404                },
405                {
406                  "textRaw": "`serializer.writeDouble(value)`",
407                  "type": "method",
408                  "name": "writeDouble",
409                  "signatures": [
410                    {
411                      "params": [
412                        {
413                          "textRaw": "`value` {number}",
414                          "name": "value",
415                          "type": "number"
416                        }
417                      ]
418                    }
419                  ],
420                  "desc": "<p>Write a JS <code>number</code> value.\nFor use inside of a custom <a href=\"#v8_serializer_writehostobject_object\"><code>serializer._writeHostObject()</code></a>.</p>"
421                },
422                {
423                  "textRaw": "`serializer.writeRawBytes(buffer)`",
424                  "type": "method",
425                  "name": "writeRawBytes",
426                  "signatures": [
427                    {
428                      "params": [
429                        {
430                          "textRaw": "`buffer` {Buffer|TypedArray|DataView}",
431                          "name": "buffer",
432                          "type": "Buffer|TypedArray|DataView"
433                        }
434                      ]
435                    }
436                  ],
437                  "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=\"#v8_serializer_writehostobject_object\"><code>serializer._writeHostObject()</code></a>.</p>"
438                },
439                {
440                  "textRaw": "`serializer._writeHostObject(object)`",
441                  "type": "method",
442                  "name": "_writeHostObject",
443                  "signatures": [
444                    {
445                      "params": [
446                        {
447                          "textRaw": "`object` {Object}",
448                          "name": "object",
449                          "type": "Object"
450                        }
451                      ]
452                    }
453                  ],
454                  "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>"
455                },
456                {
457                  "textRaw": "`serializer._getDataCloneError(message)`",
458                  "type": "method",
459                  "name": "_getDataCloneError",
460                  "signatures": [
461                    {
462                      "params": [
463                        {
464                          "textRaw": "`message` {string}",
465                          "name": "message",
466                          "type": "string"
467                        }
468                      ]
469                    }
470                  ],
471                  "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#errors_class_error\"><code>Error</code></a> constructor and can be overridden on\nsubclasses.</p>"
472                },
473                {
474                  "textRaw": "`serializer._getSharedArrayBufferId(sharedArrayBuffer)`",
475                  "type": "method",
476                  "name": "_getSharedArrayBufferId",
477                  "signatures": [
478                    {
479                      "params": [
480                        {
481                          "textRaw": "`sharedArrayBuffer` {SharedArrayBuffer}",
482                          "name": "sharedArrayBuffer",
483                          "type": "SharedArrayBuffer"
484                        }
485                      ]
486                    }
487                  ],
488                  "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=\"#v8_deserializer_transferarraybuffer_id_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>"
489                },
490                {
491                  "textRaw": "`serializer._setTreatArrayBufferViewsAsHostObjects(flag)`",
492                  "type": "method",
493                  "name": "_setTreatArrayBufferViewsAsHostObjects",
494                  "signatures": [
495                    {
496                      "params": [
497                        {
498                          "textRaw": "`flag` {boolean} **Default:** `false`",
499                          "name": "flag",
500                          "type": "boolean",
501                          "default": "`false`"
502                        }
503                      ]
504                    }
505                  ],
506                  "desc": "<p>Indicate whether to treat <code>TypedArray</code> and <code>DataView</code> objects as\nhost objects, i.e. pass them to <a href=\"#v8_serializer_writehostobject_object\"><code>serializer._writeHostObject()</code></a>.</p>"
507                }
508              ],
509              "signatures": [
510                {
511                  "params": [],
512                  "desc": "<p>Creates a new <code>Serializer</code> object.</p>"
513                }
514              ]
515            },
516            {
517              "textRaw": "Class: `v8.Deserializer`",
518              "type": "class",
519              "name": "v8.Deserializer",
520              "meta": {
521                "added": [
522                  "v8.0.0"
523                ],
524                "changes": []
525              },
526              "methods": [
527                {
528                  "textRaw": "`deserializer.readHeader()`",
529                  "type": "method",
530                  "name": "readHeader",
531                  "signatures": [
532                    {
533                      "params": []
534                    }
535                  ],
536                  "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>"
537                },
538                {
539                  "textRaw": "`deserializer.readValue()`",
540                  "type": "method",
541                  "name": "readValue",
542                  "signatures": [
543                    {
544                      "params": []
545                    }
546                  ],
547                  "desc": "<p>Deserializes a JavaScript value from the buffer and returns it.</p>"
548                },
549                {
550                  "textRaw": "`deserializer.transferArrayBuffer(id, arrayBuffer)`",
551                  "type": "method",
552                  "name": "transferArrayBuffer",
553                  "signatures": [
554                    {
555                      "params": [
556                        {
557                          "textRaw": "`id` {integer} A 32-bit unsigned integer.",
558                          "name": "id",
559                          "type": "integer",
560                          "desc": "A 32-bit unsigned integer."
561                        },
562                        {
563                          "textRaw": "`arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An `ArrayBuffer` instance.",
564                          "name": "arrayBuffer",
565                          "type": "ArrayBuffer|SharedArrayBuffer",
566                          "desc": "An `ArrayBuffer` instance."
567                        }
568                      ]
569                    }
570                  ],
571                  "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=\"#v8_serializer_transferarraybuffer_id_arraybuffer\"><code>serializer.transferArrayBuffer()</code></a> (or return the <code>id</code> from\n<a href=\"#v8_serializer_getsharedarraybufferid_sharedarraybuffer\"><code>serializer._getSharedArrayBufferId()</code></a> in the case of <code>SharedArrayBuffer</code>s).</p>"
572                },
573                {
574                  "textRaw": "`deserializer.getWireFormatVersion()`",
575                  "type": "method",
576                  "name": "getWireFormatVersion",
577                  "signatures": [
578                    {
579                      "return": {
580                        "textRaw": "Returns: {integer}",
581                        "name": "return",
582                        "type": "integer"
583                      },
584                      "params": []
585                    }
586                  ],
587                  "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>"
588                },
589                {
590                  "textRaw": "`deserializer.readUint32()`",
591                  "type": "method",
592                  "name": "readUint32",
593                  "signatures": [
594                    {
595                      "return": {
596                        "textRaw": "Returns: {integer}",
597                        "name": "return",
598                        "type": "integer"
599                      },
600                      "params": []
601                    }
602                  ],
603                  "desc": "<p>Read a raw 32-bit unsigned integer and return it.\nFor use inside of a custom <a href=\"#v8_deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
604                },
605                {
606                  "textRaw": "`deserializer.readUint64()`",
607                  "type": "method",
608                  "name": "readUint64",
609                  "signatures": [
610                    {
611                      "return": {
612                        "textRaw": "Returns: {integer[]}",
613                        "name": "return",
614                        "type": "integer[]"
615                      },
616                      "params": []
617                    }
618                  ],
619                  "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=\"#v8_deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
620                },
621                {
622                  "textRaw": "`deserializer.readDouble()`",
623                  "type": "method",
624                  "name": "readDouble",
625                  "signatures": [
626                    {
627                      "return": {
628                        "textRaw": "Returns: {number}",
629                        "name": "return",
630                        "type": "number"
631                      },
632                      "params": []
633                    }
634                  ],
635                  "desc": "<p>Read a JS <code>number</code> value.\nFor use inside of a custom <a href=\"#v8_deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
636                },
637                {
638                  "textRaw": "`deserializer.readRawBytes(length)`",
639                  "type": "method",
640                  "name": "readRawBytes",
641                  "signatures": [
642                    {
643                      "return": {
644                        "textRaw": "Returns: {Buffer}",
645                        "name": "return",
646                        "type": "Buffer"
647                      },
648                      "params": [
649                        {
650                          "textRaw": "`length` {integer}",
651                          "name": "length",
652                          "type": "integer"
653                        }
654                      ]
655                    }
656                  ],
657                  "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=\"#v8_serializer_writerawbytes_buffer\"><code>serializer.writeRawBytes()</code></a>.\nFor use inside of a custom <a href=\"#v8_deserializer_readhostobject\"><code>deserializer._readHostObject()</code></a>.</p>"
658                },
659                {
660                  "textRaw": "`deserializer._readHostObject()`",
661                  "type": "method",
662                  "name": "_readHostObject",
663                  "signatures": [
664                    {
665                      "params": []
666                    }
667                  ],
668                  "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>"
669                }
670              ],
671              "signatures": [
672                {
673                  "params": [
674                    {
675                      "textRaw": "`buffer` {Buffer|TypedArray|DataView} A buffer returned by [`serializer.releaseBuffer()`][].",
676                      "name": "buffer",
677                      "type": "Buffer|TypedArray|DataView",
678                      "desc": "A buffer returned by [`serializer.releaseBuffer()`][]."
679                    }
680                  ],
681                  "desc": "<p>Creates a new <code>Deserializer</code> object.</p>"
682                }
683              ]
684            },
685            {
686              "textRaw": "Class: `v8.DefaultSerializer`",
687              "type": "class",
688              "name": "v8.DefaultSerializer",
689              "meta": {
690                "added": [
691                  "v8.0.0"
692                ],
693                "changes": []
694              },
695              "desc": "<p>A subclass of <a href=\"#v8_class_v8_serializer\"><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>"
696            },
697            {
698              "textRaw": "Class: `v8.DefaultDeserializer`",
699              "type": "class",
700              "name": "v8.DefaultDeserializer",
701              "meta": {
702                "added": [
703                  "v8.0.0"
704                ],
705                "changes": []
706              },
707              "desc": "<p>A subclass of <a href=\"#v8_class_v8_deserializer\"><code>Deserializer</code></a> corresponding to the format written by\n<a href=\"#v8_class_v8_defaultserializer\"><code>DefaultSerializer</code></a>.</p>"
708            }
709          ],
710          "type": "module",
711          "displayName": "Serialization API"
712        }
713      ],
714      "type": "module",
715      "displayName": "V8"
716    }
717  ]
718}