MCPcopy Create free account
hub / github.com/TanStack/router / encodeFrame

Function encodeFrame

packages/start-client-core/tests/frame-decoder.test.ts:37–49  ·  view source on GitHub ↗

* Helper to encode a frame for testing

(
  type: number,
  streamId: number,
  payload: Uint8Array,
)

Source from the content-addressed store, hash-verified

35 * Helper to encode a frame for testing
36 */
37function encodeFrame(
38 type: number,
39 streamId: number,
40 payload: Uint8Array,
41): Uint8Array {
42 const frame = new Uint8Array(FRAME_HEADER_SIZE + payload.length)
43 const view = new DataView(frame.buffer)
44 view.setUint8(0, type)
45 view.setUint32(1, streamId, false)
46 view.setUint32(5, payload.length, false)
47 frame.set(payload, FRAME_HEADER_SIZE)
48 return frame
49}
50
51function encodeJSONFrame(json: string): Uint8Array {
52 return encodeFrame(FRAME_TYPE_JSON, 0, new TextEncoder().encode(json))

Callers 6

encodeJSONFrameFunction · 0.70
encodeChunkFrameFunction · 0.70
encodeEndFrameFunction · 0.70
encodeErrorFrameFunction · 0.70
startFunction · 0.70

Calls 1

setMethod · 0.65

Tested by

no test coverage detected