Skip to content

Getting Started

Gives tools to describe binary structures with full TypeScript support. Encodes and decodes into pure JavaScript objects, while giving type context for the parsed data.

npm install --save typed-binary
import bin from 'typed-binary';
// Define a schema
const Vec2f = bin.tupleOf([bin.f32, bin.f32]);
const Vec2fSize = Vec2f.measure(bin.MaxValue).size;
const buffer = new ArrayBuffer(Vec2fSize);
Vec2f.write(new bin.BufferWriter(buffer), [0.5, 3.14]);
import bin from 'typed-binary';
// Define a schema
const Vec2f = bin.tupleOf([bin.f32, bin.f32]);
const Vec2fSize = Vec2f.measure(bin.MaxValue).size;
const buffer = Buffer.alloc(Vec2fSize);
Vec2f.write(new bin.BufferWriter(buffer), [0.5, 3.14]);