Wraps a byte array for data serialization and deserialization.
const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello" const buffer = new Editor.Buffer(bytes); // Round-trip: toBytes() recovers the original byte array const roundTripped = buffer.toBytes(); const matches = roundTripped.every((b: number, i: number) => b === bytes[i]); console.log(`Buffer "${buffer.toString()}" (${roundTripped.length} bytes), round-trip match: ${matches}`); Copy
const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello" const buffer = new Editor.Buffer(bytes); // Round-trip: toBytes() recovers the original byte array const roundTripped = buffer.toBytes(); const matches = roundTripped.every((b: number, i: number) => b === bytes[i]); console.log(`Buffer "${buffer.toString()}" (${roundTripped.length} bytes), round-trip match: ${matches}`);
Create a buffer from a byte array.
Return the underlying byte array.
Return the buffer contents as a UTF-8 string.
Wraps a byte array for data serialization and deserialization.
Example