Files
2026-05-27 23:47:53 +01:00

9.6 KiB

@suaveplan/bitpacker-streaming - Bitpacker streaming plugin

Summary

Streaming APIs for bitpacker including chunked packing/unpacking and true TransformStream support with framing.

Documentation tree

  • defaults — (no submodules)
  • otel — (no submodules)
  • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…
    • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…
  • streaming-bit-packer — (no submodules) - streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer — (no submodules) - streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer.schema — Zod schemas for the option bundles consumed by StreamingBitPacker and its peer streaming helpers (packStream, `unpa…
  • transform — (no submodules) - transform.schema — Zod schemas for the option bundl…
    • transform — (no submodules) - transform.schema — Zod schemas for the option bundl…
    • transform.schema — Zod schemas for the option bundles consumed by createPackTransformStream, createUnpackTransformStream, and the fram…
  • index — Path: bitpacker-streaming/src/index.ts Export: See source for details.
- [default-clock](./src/defaults/default-clock.md) — _(no submodules)_- [otel](./src/otel/instruments.md) — _(no submodules)_- [instruments](./src/otel/instruments.md) — _(no submodules)_- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
  • streaming-bit-packer — (no submodules)- streaming-bit-packer.schema — Zod schemas for the o…
  • streaming-bit-packer.schema — Zod schemas for the option bundles consumed by StreamingBitPacker and its peer streaming helpers (packStream, `unpa…
  • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform.schema — Zod schemas for the option bundles consumed by createPackTransformStream, createUnpackTransformStream, and the fram…
  • index — Path: bitpacker-streaming/src/index.ts Export: See source for details.
  • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…
  • default-clock — (no submodules)- otel — (no submodules)- instruments — (no submodules)- streaming-bit-packer — (no submodules)- streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer — (no submodules)- streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer.schema — Zod schemas for the option bundles consumed by StreamingBitPacker and its peer streaming helpers (packStream, `unpa…
  • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform.schema — Zod schemas for the option bundles consumed by createPackTransformStream, createUnpackTransformStream, and the fram…
  • index — Path: bitpacker-streaming/src/index.ts Export: See source for details.
  • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…
  • default-clock — (no submodules)- otel — (no submodules)- instruments — (no submodules)- streaming-bit-packer — (no submodules)- streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer — (no submodules)- streaming-bit-packer.schema — Zod schemas for the o…
    • streaming-bit-packer.schema — Zod schemas for the option bundles consumed by StreamingBitPacker and its peer streaming helpers (packStream, `unpa…
  • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform — (no submodules)- transform.schema — Zod schemas for the option bundl…
    • transform.schema — Zod schemas for the option bundles consumed by createPackTransformStream, createUnpackTransformStream, and the fram…
  • index — Path: bitpacker-streaming/src/index.ts Export: See source for details.
  • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…
  • default-clock — (no submodules)- otel — (no submodules) - instruments — (no submodules)- streaming-bit-packer — (no submodules) - streaming-bit-packer — (no submodules) - streaming-bit-packer.schema — Zod schemas for the option bundles consumed by StreamingBitPacker and its peer streaming helpers (packStream, `unpa…
  • transform — (no submodules) - transform — (no submodules) - transform.schema — Zod schemas for the option bundles consumed by createPackTransformStream, createUnpackTransformStream, and the fram…
  • index — Path: bitpacker-streaming/src/index.ts Export: See source for details.
  • register-schemas — Idempotent integration with @suaveplan/schema-registry for the @suaveplan/bitpacker-streaming package. Exposes `reg…

Install

bun add @suaveplan/bitpacker-streaming

Usage

import { BitPacker } from "@suaveplan/bitpacker";
import { registerDefaultStrategies } from "@suaveplan/bitpacker-strategies";
import { packToChunks, unpackFromChunks, createFramedPackStream, createFramedUnpackStream } from "@suaveplan/bitpacker-streaming";

const bp = new BitPacker();
registerDefaultStrategies(bp.strategyManager);
const schema = 255;

// Chunked packing
const chunks = packToChunks(42, schema, { chunkSize: 2 });
const value = unpackFromChunks<number>(chunks, schema);

// Transform streams with framing
const packStream = createFramedPackStream(bp, schema);
const unpackStream = createFramedUnpackStream(bp, schema);
packStream.readable.pipeTo(unpackStream.writable);

const writer = packStream.writable.getWriter();
await writer.write(42);
await writer.close();

const reader = unpackStream.readable.getReader();
const { value } = await reader.read(); // 42

Modules

  • src/index.ts — packToChunks, unpackFromChunks, unpackFromChunksAsync
  • src/transform/transform.ts — TransformStream factories with length-prefix, delimiter, fixed-size, and no-framing options