Skip to content

bint()

ts
(): BintInstance;

Creates a new empty BintInstance that can store numbers in a compact binary format.

Returns

A new BintInstance that you can call with numbers to add them to the array.

Example

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

const instance = bint();
instance(42);        // Add 42 as Uint8
instance(3.14);      // Add 3.14 as Float32
instance(1000000);   // Add 1000000 as Uint32

console.log(instance.length); // 3
console.log(instance[0]);     // 42
console.log(instance.at(1));  // 3.14

const buffer = instance.toBuffer(); // Serialize to ArrayBuffer

References