MCPcopy Index your code
hub / github.com/codeaashu/claude-code / decodeChunk

Function decodeChunk

src/upstreamproxy/relay.ts:87–103  ·  view source on GitHub ↗
(buf: Uint8Array)

Source from the content-addressed store, hash-verified

85 * Tolerates the server sending a zero-length chunk (keepalive semantics).
86 */
87export function decodeChunk(buf: Uint8Array): Uint8Array | null {
88 if (buf.length === 0) return new Uint8Array(0)
89 if (buf[0] !== 0x0a) return null
90 let len = 0
91 let shift = 0
92 let i = 1
93 while (i < buf.length) {
94 const b = buf[i]!
95 len |= (b & 0x7f) << shift
96 i++
97 if ((b & 0x80) === 0) break
98 shift += 7
99 if (shift > 28) return null
100 }
101 if (i + len > buf.length) return null
102 return buf.subarray(i, i + len)
103}
104
105export type UpstreamProxyRelay = {
106 port: number

Callers 1

openTunnelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected