encodeHeaderInto
encodeHeaderInto(
buffer,header):void
Defined in: packages/protocol/src/wire-format.ts:165
Encode a frame header INTO an existing buffer (zero allocation).
Use this with a pre-allocated buffer to avoid allocation overhead in high-throughput scenarios (e.g., ring buffer pattern).
Parameters
Section titled “Parameters”buffer
Section titled “buffer”Buffer
Target buffer (must be at least HEADER_SIZE bytes)
header
Section titled “header”Header to encode
Returns
Section titled “Returns”void
Example
Section titled “Example”const headerBuf = Buffer.allocUnsafe(HEADER_SIZE);encodeHeaderInto(headerBuf, { methodId: 1, flags: 0, requestId: 42, payloadLength: 1024,});socket.write(headerBuf);