Documentation / @andrew_l/tl-pack / Structure / Structure
Interface: Structure<T> ​
Type Parameters ​
T ​
T extends Data = Data
Properties ​
value ​
readonlyvalue:T
The structured data value
Example ​
ts
const user = new UserStruct({ id: 1, name: 'Alice' });
console.log(user.value.name); // 'Alice'Methods ​
toBuffer() ​
toBuffer(
options?):Uint8Array
Serializes the structure to a binary buffer
Parameters ​
options? ​
Writer configuration options
Returns ​
Uint8Array
Serialized binary data
Examples ​
ts
const user = new User({ id: 1, name: 'Alice' });
const buffer = user.toBuffer();
console.log(buffer.length); // Size in bytests
// With custom writer options
const buffer = user.toBuffer({
initialSize: 1024,
growthFactor: 2
});