(json: object)
| 91 | const HEADER_SIZE = 8; // 4 magic + 4 uint32LE length |
| 92 | |
| 93 | function encodePacket(json: object): Buffer { |
| 94 | const payload = Buffer.from(JSON.stringify(json), 'utf8'); |
| 95 | const header = Buffer.alloc(8); |
| 96 | MAGIC.copy(header, 0); |
| 97 | header.writeUInt32LE(payload.length, 4); |
| 98 | return Buffer.concat([header, payload]); |
| 99 | } |
| 100 | |
| 101 | // ─── DaemonConnection ──────────────────────────────────────────────────────── |
| 102 |
no test coverage detected