MCPcopy Create free account
hub / github.com/Alex6357/alloy / writeString

Method writeString

frontend/src/alloy/buffer.ts:60–73  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

58 }
59
60 writeString(value: string): void {
61 const encoded = this.stringEncoder.encode(value);
62 const len = encoded.length;
63
64 // Write length as u32 first
65 if (this.cursor + 4 > this.buffer.length) this.expand();
66 this.view.setUint32(this.cursor, len, true);
67 this.cursor += 4;
68
69 // Write string bytes
70 if (this.cursor + len > this.buffer.length) this.expand();
71 this.buffer.set(encoded, this.cursor);
72 this.cursor += len;
73 }
74
75 flush(): Uint8Array {
76 return this.buffer.slice(0, this.cursor);

Callers

nothing calls this directly

Calls 1

expandMethod · 0.95

Tested by

no test coverage detected