Skip to main content
The Bun adapter uses Bun’s built-in bun:ffi module to call the Zinc C ABI directly. No native addon compilation is needed. Bun loads libzinc_core at runtime through its FFI layer.

Installation

Build the core from a source checkout, then set up the adapter:

SharedRegion

create

Creates a new region. Throws on failure.

open

Opens an existing region.

buffer

Returns a Buffer backed by the shared memory mapping. Uses bun:ffi’s toBuffer function for zero-copy access.

notify

wait

Returns true on notification, false on timeout.

close

The region also supports Symbol.dispose for using statements:

Complete example

FFI details

Handles are numeric pointers in Bun’s FFI API. zinc_ptr returns the data pointer and toBuffer wraps it without copying. The loader resolves target/release/libzinc_core.{so,dylib} relative to the source checkout. Keep the region open while any returned buffer is in use. close() is idempotent and later operations on the region throw. tryWait() consumes a pending notification without blocking. Timeouts must be integers between 0 and 2^32 - 1 milliseconds.