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

Sir Dez

Glorious SerDes for TypeScript

The library you can rely on,
For binary serialization and deserialization,
In Node, Deno, and the Web environment,
Which is simple and yet performant.

ci npm deno coverage report

Getting Started

Installation

Node (Webpack, Babel, React, Svelte, Vue, Svelte…)
In the terminal with NPM
npm i sirdez
Or with Yarn
yarn add sirdez
In the code with ES Modules
import * as sirdez from "sirdez";
or with CommonJS
const sirdez = require("sirdez");
Web (without bundlers)
In HTML with UMD
<script src="https://cdn.jsdelivr.net/npm/sirdez@latest/dist/sirdez.umd.js"></script>
In an ES module script (statically)
import * as sirdez from "https://cdn.jsdelivr.net/npm/sirdez@latest/dist/sirdez.umd.js";
In an ES module script (dynamically)
const sirdez = await import(
  "https://cdn.jsdelivr.net/npm/sirdez@latest/dist/sirdez.umd.js"
);
Deno
In code (statically)
import * as sirdez from "https://deno.land/x/sirdez";
In code (dynamically)
const sirdez = await import("https://deno.land/x/sirdez");

Usage

Simple snippet of code

// create person typer
const personTyper = sirdez.struct({
  name: sirdez.string,
  age: sirdez.uint8
});

// use person typer
const { encode, decode } = sirdez.use(personTyper);

// encode
const encoded = encode({
  name: "Bob",
  age: 23
});
console.log("encoded", encoded);

// decode
const decoded = decode(encoded);
console.log("decoded", decoded);

// celebrate
console.log("🍷Cheers!🍺");

Using TypeScript utilities

type Person = sirdez.TypeOf<typeof personTyper>;

const bob: Person = {
  name: "Bob",
  age: 23
};