1.0.2
A simple parser for easily creating both encoding and decoding for a given data type
Repository
Current version released
4 years ago
Binary parser
A simple parser for easily creating both encoding and decoding for a given data type
This project has no dependencies and should work in any typescript environment although it was developed mainly for deno
Running tests
deno test🎉 Getting started
Import what you need from mod.ts
✏️ Docs
Can be found at https://github.com/glooca/parser/wiki
There’s also deno’s auto generated docs
:pencil2: Example
import {
coderFactory,
nullTermStr,
pad,
u32,
} from "https://deno.land/x/binary_parser/mod.ts";
interface MyInterface {
someProp: number;
anotherProp: string;
}
const myCoder = coderFactory<MyInterface>((r) => {
r(u32(), "someProp");
r(pad(2));
r(nullTermStr, "anotherProp");
});
const myData: MyInterface = { someProp: 420, anotherProp: "Hello, World!" };
const encoded: Uint8Array = await myCoder.encode(myData);
const decoded: MyInterface = await myCoder.decode(encoded);
// assertEqual(myData, decoded);