Skip to main content
Deno 2 is finally here 🎉️
Learn more

Binary parser Deno Coverage

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

:pencil2: Example

import { coderFactory, nullTermStr, pad, u32 } from "./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);