@the-link/messagepack
v0.1.0
Published
Type-preserving MessagePack utilities for The Link.
Downloads
502
Readme
The Link MessagePack
Type-preserving MessagePack utilities for values carried through The Link. The package defines a serialization policy; no adapter is required to use it.
Install
npm install @the-link/messagepackUsage
import { deserialize, serialize } from "@the-link/messagepack"
const bytes = serialize({ createdAt: new Date(), data: new Uint8Array([1, 2, 3]) })
const value = deserialize(bytes)Adapters that expose codec selection can use the functions directly:
client.setSerialize(serialize)
client.setDeserialize(deserialize)The transmitted value model preserves undefined, bigint, Date, Map,
Set, RegExp, URL, Error, and binary data. Array buffers and typed-array
views are normalized to Uint8Array. Functions and symbols become null,
function-valued object properties are omitted, and ordinary class prototypes
are not transmitted. Transmitted<T> describes these transformations.
Attachments
Values already carried by a boundary can be referenced without encoding them inside the MessagePack payload:
const bytes = serialize({ file }, [file])
const value = deserialize(bytes, [file])The boundary owns attachment transport and must supply the same ordered list to both operations. The codec only records and resolves attachment indices.
Development
bun install --frozen-lockfile
bun run verifyLicense
MIT
