@insler/serde-msgpack
The MessagePack adapter package: msgpackSerde, a Serde<Uint8Array>
backed by @msgpack/msgpack.
Reach for it when compact binary encoding matters on a binary wire.
bun add @insler/serde-msgpackmsgpackSerde — Serde<Uint8Array>
Section titled “msgpackSerde — Serde<Uint8Array>”import { msgpackSerde } from '@insler/serde-msgpack';
const bytes = msgpackSerde.encode({ id: 'ord-1', quantity: 3, price: 19.5 });// Uint8Array — MessagePack-encoded
const order = msgpackSerde.decode(bytes);// { id: 'ord-1', quantity: 3, price: 19.5 }It honors the shared serde conventions: encode(undefined) produces empty
bytes, decoding empty bytes returns undefined.
Interchangeable behind the interface
Section titled “Interchangeable behind the interface”msgpackSerde is a standard Serde<Uint8Array> — swap it with
jsonBytesSerde, cborSerde,
or an Avro serde wherever a binary serde is
accepted, such as the rpc subsystem’s NATS
transport serde option. Develop on JSON, deploy on MessagePack, without
touching a call site.
Boundaries
Section titled “Boundaries”Depends on @insler/serde (the interface) and @msgpack/msgpack — it stays
transport-agnostic, a pure Serde<Uint8Array> with no transport-specific
assumptions.