Repository
Current version released
3 years ago
SerDes for TypeScript
GloriousThe library you can rely on,
For binary serialization and deserialization,
In Node, Deno, and the Web environment,
Which is simple and yet performant.
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/dist/sirdez.umd.js"></script>
In an ES module script (statically)
import * as sirdez from "https://cdn.jsdelivr.net/npm/sirdez/dist/sirdez.es.js";
In an ES module script (dynamically)
const sirdez = await import(
"https://cdn.jsdelivr.net/npm/sirdez/dist/sirdez.es.js"
);
Deno
In code (statically)
import * as sirdez from "https://deno.land/x/sirdez/mod.ts";
In code (dynamically)
const sirdez = await import("https://deno.land/x/sirdez/mod.ts");
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
};