LogoPear Docs
ReferencesBareModules

bare-inspector

Reference for bare-inspector: V8 inspector support for Bare—drive the inspector protocol from a session and capture heap snapshots.

stable

bare-inspector exposes the V8 inspector protocol to Bare programs: open a Session, send protocol commands, receive notifications, and capture heap snapshots. It's the in-process counterpart to the bare --inspect flag, and what pear-inspect exposes remotely over Hyperswarm. It's a native addon and requires Bare >=1.25.0 <1.29.0.

npm i bare-inspector

Usage

const { Session } = require('bare-inspector')

const session = new Session()
session.connect()

const { result } = await session.post('Runtime.evaluate', { expression: '1 + 2' })
console.log(result)

API

Session

const session = new Session()

Create an inspector session.

session.connect() · session.post(method[, params]) · session.destroy()

Connect, send an inspector-protocol command (returns its result), and tear down.

session.on('<inspector-protocol-method>', message) · session.on('inspectorNotification', message)

Subscribe to a specific protocol notification, or all of them.

HeapSnapshot

const snapshot = new HeapSnapshot(session)

Capture a heap snapshot; iterate it for chunks with for await (const chunk of snapshot).

Builds on bare-events, bare-http1, bare-stream, bare-url, and bare-ws.

See also

On this page