MCPcopy Create free account
hub / github.com/Snapchat/Valdi / encodePacket

Function encodePacket

npm_modules/cli/src/utils/daemonClient.ts:93–99  ·  view source on GitHub ↗
(json: object)

Source from the content-addressed store, hash-verified

91const HEADER_SIZE = 8; // 4 magic + 4 uint32LE length
92
93function 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

Callers 3

dispatchMessageMethod · 0.85
sendRequestMethod · 0.85
forwardAndWaitMethod · 0.85

Calls 3

copyMethod · 0.65
fromMethod · 0.45
concatMethod · 0.45

Tested by

no test coverage detected