9.6 KiB
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)
- default-clock — (no submodules)
- otel — (no submodules)
- instruments — (no submodules)
- register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. Exposes `reg…- register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. Exposes `reg…
- register-schemas — Idempotent integration with
- 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
StreamingBitPackerand 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.tsExport: See source for details.
- 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
StreamingBitPackerand 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.tsExport: See source for details. - register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. 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
StreamingBitPackerand 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.tsExport: See source for details. - register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. 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
StreamingBitPackerand 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.tsExport: See source for details. - register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. 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
StreamingBitPackerand 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.tsExport: See source for details. - register-schemas — Idempotent integration with
@suaveplan/schema-registryfor the@suaveplan/bitpacker-streamingpackage. 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,unpackFromChunksAsyncsrc/transform/transform.ts—TransformStreamfactories with length-prefix, delimiter, fixed-size, and no-framing options