LogoPear Docs
ReferencesBareModules

bare-structured-clone

Reference for bare-structured-clone: the HTML structured-clone algorithm for Bare—structuredClone plus low-level serialize/deserialize with transfer.

stable

bare-structured-clone implements the HTML structured-clone algorithm for Bare: the structuredClone function plus the low-level serialize/deserialize primitives that inter-thread messaging (bare-channel) is built on. It's a native addon and requires Bare >=1.2.0.

npm i bare-structured-clone

Usage

const structuredClone = require('bare-structured-clone')

const copy = structuredClone({ hello: 'world' })

const buffer = new ArrayBuffer(4)
const transferred = structuredClone(buffer, { transfer: [buffer] })

Require bare-structured-clone/global to install structuredClone as a global.

API

const copy = structuredClone(value[, options])

Deep-clone a value, optionally transferring objects via options.transfer.

Low-level serialization

serialize(value[, forStorage[, interfaces]]) · serializeWithTransfer(value[, transferList[, interfaces]])

Produce a serialized representation, optionally with a transfer list.

deserialize(serialized[, interfaces]) · deserializeWithTransfer(serialized[, interfaces])

Reconstruct a value from its serialized form.

preencode(state, serialized) · encode(state, serialized) · const serialized = decode(state)

The wire codec used to move serialized values across a boundary, plus constants, symbols, and the Serializable / Transferable base classes for custom types.

Builds on bare-buffer, bare-type, and bare-url (see Bare modules).

See also

On this page