Skip to content

bint.fromBuffer()

Property of bint

ts
fromBuffer(buffer: ArrayBuffer): BintInstance

Deserializes an ArrayBuffer created by BintInstance.toBuffer() back into a BintInstance.

Parameters

  • buffer: The ArrayBuffer containing the serialized binary data.

Returns

A new BintInstance with the deserialized numbers.

Example

ts
import bint from '@briklab/net-t';

// Create and serialize
const original = bint();
original(42);
original(3.14);
const buffer = original.toBuffer();

// Deserialize
const restored = bint.fromBuffer(buffer);
console.log(restored.length); // 2
console.log(restored[0]);     // 42
console.log(restored[1]);     // 3.14

Throws

  • Error: If the buffer contains invalid type IDs or has incorrect length.

References