construction
🚧 Interface with binary structures in Javascript, built for network protocols.
Features
- Small, concise codebase with no dependencies.
- Full test suite, testing every type.
- Supports, Int8, Int16, Int32, UInt8, UInt16, UInt32.
To Do
- Add char and array types.
struct User {uint8_t age;int32_t favouriteNumber;}
const Construction = ;const t = Constructiontypes;const User = "LE"age: tUInt8;favouriteNumber: tInt32;
API
new Construction(endianness, object)
Create a new construction object.
// Endianness can be "LE" or "BE"const User = "LE"age: tUInt8favouriteNumber: tInt32;
buffer Construction#write(object)
Convert a javascript object to a binary buffer.
const buffer = User;console;// <Buffer 0f 40 42 0f 00>
object Construction#read(buffer)
Convert a binary buffer to a javascript object.
const user = User;console;// { age: 15, favouriteNumber: 1000000 }