90 lines
9.6 KiB
Markdown
90 lines
9.6 KiB
Markdown
# @suaveplan/bitpacker-streaming - Bitpacker streaming plugin
|
|
|
|
## Summary
|
|
|
|
Streaming APIs for bitpacker including chunked packing/unpacking and true TransformStream support with framing.
|
|
|
|
<!-- begin:auto-docs -->
|
|
## Documentation tree
|
|
|
|
- [defaults](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [default-clock](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [otel](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [instruments](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs -->
|
|
- [register-schemas](./src/register-schemas/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
- [register-schemas](./src/register-schemas/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs --> - streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs --> - streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer.schema](./src/streaming-bit-packer/streaming-bit-packer.schema.md) — Zod schemas for the option bundles consumed by `StreamingBitPacker` and its peer streaming helpers (`packStream`, `unpa…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs --> - transform.schema — Zod schemas for the option bundl…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_ <!-- end:auto-docs --> - transform.schema — Zod schemas for the option bundl…
|
|
- [transform.schema](./src/transform/transform.schema.md) — Zod schemas for the option bundles consumed by `createPackTransformStream`, `createUnpackTransformStream`, and the fram…
|
|
- [index](./src/index.md) — **Path:** `bitpacker-streaming/src/index.ts` **Export:** See source for details.
|
|
<!-- end:auto-docs --> - [default-clock](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_- [otel](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [instruments](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer.schema](./src/streaming-bit-packer/streaming-bit-packer.schema.md) — Zod schemas for the option bundles consumed by `StreamingBitPacker` and its peer streaming helpers (`packStream`, `unpa…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform.schema](./src/transform/transform.schema.md) — Zod schemas for the option bundles consumed by `createPackTransformStream`, `createUnpackTransformStream`, and the fram…
|
|
- [index](./src/index.md) — **Path:** `bitpacker-streaming/src/index.ts` **Export:** See source for details.
|
|
- [register-schemas](./src/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
- [default-clock](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_- [otel](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [instruments](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer.schema](./src/streaming-bit-packer/streaming-bit-packer.schema.md) — Zod schemas for the option bundles consumed by `StreamingBitPacker` and its peer streaming helpers (`packStream`, `unpa…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform.schema](./src/transform/transform.schema.md) — Zod schemas for the option bundles consumed by `createPackTransformStream`, `createUnpackTransformStream`, and the fram…
|
|
- [index](./src/index.md) — **Path:** `bitpacker-streaming/src/index.ts` **Export:** See source for details.
|
|
- [register-schemas](./src/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
- [default-clock](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_- [otel](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [instruments](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_- streaming-bit-packer.schema — Zod schemas for the o…
|
|
- [streaming-bit-packer.schema](./src/streaming-bit-packer/streaming-bit-packer.schema.md) — Zod schemas for the option bundles consumed by `StreamingBitPacker` and its peer streaming helpers (`packStream`, `unpa…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_- transform.schema — Zod schemas for the option bundl…
|
|
- [transform.schema](./src/transform/transform.schema.md) — Zod schemas for the option bundles consumed by `createPackTransformStream`, `createUnpackTransformStream`, and the fram…
|
|
- [index](./src/index.md) — **Path:** `bitpacker-streaming/src/index.ts` **Export:** See source for details.
|
|
- [register-schemas](./src/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
- [default-clock](./src/defaults/default-clock.md) — <!-- begin:auto-docs --> _(no submodules)_- [otel](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_ - [instruments](./src/otel/instruments.md) — <!-- begin:auto-docs --> _(no submodules)_- [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_ - [streaming-bit-packer](./src/streaming-bit-packer/streaming-bit-packer.md) — <!-- begin:auto-docs --> _(no submodules)_ - [streaming-bit-packer.schema](./src/streaming-bit-packer/streaming-bit-packer.schema.md) — Zod schemas for the option bundles consumed by `StreamingBitPacker` and its peer streaming helpers (`packStream`, `unpa…
|
|
- [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_ - [transform](./src/transform/transform.md) — <!-- begin:auto-docs --> _(no submodules)_ - [transform.schema](./src/transform/transform.schema.md) — Zod schemas for the option bundles consumed by `createPackTransformStream`, `createUnpackTransformStream`, and the fram…
|
|
- [index](./src/index.md) — **Path:** `bitpacker-streaming/src/index.ts` **Export:** See source for details.
|
|
- [register-schemas](./src/register-schemas.md) — Idempotent integration with `@suaveplan/schema-registry` for the `@suaveplan/bitpacker-streaming` package. Exposes `reg…
|
|
|
|
## Install
|
|
|
|
```bash
|
|
bun add @suaveplan/bitpacker-streaming
|
|
```
|
|
|
|
## Usage
|
|
|
|
```typescript
|
|
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
|