# node:v8

> How Elide supports Node's `v8` module: six exports, including heap statistics and a JSON-based `serialize` that is not V8's structured-clone format.

`node:v8` exports six members of [Node's `v8`](https://nodejs.org/api/v8.html).

## Example

```js
// v8.mjs
import v8 from "node:v8";

const bytes = v8.serialize({ id: 7, tags: ["a"] });
console.log(JSON.stringify(v8.deserialize(bytes)));
const heap = v8.getHeapStatistics();
console.log(heap.used_heap_size > 0, heap.total_heap_size >= heap.used_heap_size);
console.log(typeof v8.cachedDataVersionTag());
```

`elide run v8.mjs` prints:

```text
{"id":7,"tags":["a"]}
true true
number
```

## Differences from Node

Only these members are exported:

| Operation | Behavior |
|---|---|
| `cachedDataVersionTag()` | Returns a stable 32-bit tag for the running binary. |
| `getHeapStatistics()` | Returns a heap-statistics object in Node's format. |
| `getHeapSpaceStatistics()` | Returns one entry per memory pool, with names such as `eden space`. |
| `setFlagsFromString(flags)` | Accepts a string and has no effect. |
| `serialize(value)` | Encodes `JSON.stringify(value)` as UTF-8 in a `Uint8Array`. |
| `deserialize(buffer)` | Decodes UTF-8 and parses the JSON. |

`serialize` output is not V8's structured-clone format; circular objects throw `TypeError`.

<!-- api-reference:start 51935d7f798e -->
## Reference

**Status:** Partial · Not measured · since 1.1.0

### Exports

| Export | Kind | Status | Notes |
| --- | --- | --- | --- |
| `getHeapStatistics()` | function | Full | Returns an object with V8 heap statistics |
| `getHeapSpaceStatistics()` | function | Full | Returns statistics about V8 heap spaces |
| `setFlagsFromString()` | function | Full | Set additional V8 command-line flags |
| `serialize()` | function | Full | Serializes a value into a buffer |
| `deserialize()` | function | Full | Reads a value written by serialize() from a buffer |

### Not implemented

`DefaultDeserializer`, `DefaultSerializer`, `Deserializer`, `GCProfiler`, `Serializer`, `getCppHeapStatistics`, `getHeapCodeStatistics`, `getHeapSnapshot`, `isStringOneByteRepresentation`, `promiseHooks`, `queryObjects`, `setHeapSnapshotNearHeapLimit`, `startCpuProfile`, `startHeapProfile`, `startupSnapshot`, `stopCoverage`, `takeCoverage`, `writeHeapSnapshot`.
<!-- api-reference:end -->
