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.
Install
npm install --save typed-binary
Use in the browser
import bin from ' typed-binary ' ;
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 ]);
Use in Node.js
import bin from ' typed-binary ' ;
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 ]);