Frame
Defined in: packages/protocol/src/frame-buffer.ts:67
Complete frame extracted from the stream.
PERFORMANCE OPTIMIZATION: Payload is stored as an array of chunks (Zero-Copy) to avoid premature memory allocation and copying for large payloads.
Use payloadChunks for streaming/piping (zero-copy).
Use payload only when codec requires contiguous buffer.
MEMORY WARNING:
The chunks are subarrays of original socket buffers. Due to Node.js
Slab Allocation, holding a small Frame for long time may prevent GC
of larger memory blocks. If you need to store frames long-term,
copy the payload: Buffer.from(frame.payload)
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Frame(
header,_chunks,_totalLength):Frame
Defined in: packages/protocol/src/frame-buffer.ts:68
Parameters
Section titled “Parameters”header
Section titled “header”_chunks
Section titled “_chunks”Buffer<ArrayBufferLike>[]
_totalLength
Section titled “_totalLength”number
Returns
Section titled “Returns”Frame
Properties
Section titled “Properties”header
Section titled “header”
readonlyheader:FrameHeader
Defined in: packages/protocol/src/frame-buffer.ts:69
Accessors
Section titled “Accessors”payload
Section titled “payload”Get Signature
Section titled “Get Signature”get payload():
Buffer
Defined in: packages/protocol/src/frame-buffer.ts:96
Returns the payload as a single contiguous Buffer.
⚠️ WARNING: This performs memory allocation + copy!
Use ONLY when the codec requires a contiguous block.
For large payloads (100MB+), this is EXPENSIVE.
Prefer payloadChunks when possible.
Returns
Section titled “Returns”Buffer
payloadChunks
Section titled “payloadChunks”Get Signature
Section titled “Get Signature”get payloadChunks(): readonly
Buffer<ArrayBufferLike>[]
Defined in: packages/protocol/src/frame-buffer.ts:83
Returns the payload as raw chunks (ZERO-COPY).
BEST PERFORMANCE for:
- Streaming to another socket
- Writing to file (fs.writev)
- Raw binary processing
- When you can process chunk-by-chunk
Returns
Section titled “Returns”readonly Buffer<ArrayBufferLike>[]
payloadLength
Section titled “payloadLength”Get Signature
Section titled “Get Signature”get payloadLength():
number
Defined in: packages/protocol/src/frame-buffer.ts:105
Total payload length in bytes.
Returns
Section titled “Returns”number