(socket: net.Socket, obj: unknown)
| 5 | * Format: 4-byte big-endian length + JSON payload |
| 6 | */ |
| 7 | export function writeFrame(socket: net.Socket, obj: unknown): void { |
| 8 | const json = Buffer.from(JSON.stringify(obj), 'utf8'); |
| 9 | const header = Buffer.alloc(4); |
| 10 | header.writeUInt32BE(json.length, 0); |
| 11 | socket.write(Buffer.concat([header, json])); |
| 12 | } |
| 13 | |
| 14 | /** |
| 15 | * Create a frame reader that buffers incoming data and emits complete messages. |
no test coverage detected