Skip to content

RawChunksCodec

Defined in: packages/codecs/src/raw-codec.ts:78

RawChunksCodec - TRUE ZERO-COPY. Returns Buffer[] (array of chunks).

✅ BEST FOR:

  • Streaming large files to disk
  • Piping to other sockets
  • Processing huge datasets chunk-by-chunk
  • Any scenario where you want to avoid memory allocation
const codec = new RawChunksCodec();
// Serialize (accepts multiple buffers)
const payload = codec.serialize([chunk1, chunk2]);
// Deserialize - returns chunks without copying!
const chunks = codec.deserializeChunks(receivedChunks);
// chunks[0] === receivedChunks[0] (same reference!)
  • Codec<Buffer[], Buffer[]>

new RawChunksCodec(): RawChunksCodec

RawChunksCodec

readonly name: "raw-chunks" = "raw-chunks"

Defined in: packages/codecs/src/raw-codec.ts:79

Human-readable codec name for debugging/logging.

Codec.name

deserialize(buffer): Buffer<ArrayBufferLike>[]

Defined in: packages/codecs/src/raw-codec.ts:90

Deserialize from a single merged buffer.

⚠️ WARNING: If called for large payloads, this implies a memory copy happened earlier (chunks were merged).

Buffer

Binary data to deserialize

Buffer<ArrayBufferLike>[]

Deserialized data

Codec.deserialize


deserializeChunks(chunks): Buffer<ArrayBufferLike>[]

Defined in: packages/codecs/src/raw-codec.ts:98

✅ ZERO-COPY: Returns the array with the same Buffer references. No data is copied - only the array wrapper is new!

readonly Buffer<ArrayBufferLike>[]

Buffer<ArrayBufferLike>[]

Codec.deserializeChunks


serialize(data): Buffer

Defined in: packages/codecs/src/raw-codec.ts:81

Serialize data to binary format.

Buffer<ArrayBufferLike>[]

Data to serialize

Buffer

Binary representation as Buffer

Codec.serialize