Skip to content

Minimal and modular binary schema-full protocol for TypeScript.

License

Notifications You must be signed in to change notification settings

the-minimal/protocol

Repository files navigation

protocol

Types

Boolean

{
   type: "boolean";
}

Int

{
   type: "int";
   size?: 8 | 16 | 32;  // default: 8
   signed?: boolean;  // default: false
}

Float

{
   type: "float";
   size?: 32 | 64;  // default: 32 
}

String

{
   type: "string";
   kind?: "ascii" | "utf8" | "utf16";  // default: "ascii"
   size?: 8 | 16;  // default: 8
}

Object

{
   type: "object";
   item: TypeWithKey[];
   size?: 8 | 16;  // default: 8
}

Array

{
   type: "array";
   item: Type | TypeName;
   size?: 8 | 16;  // default: 8
}

Tuple

{
   type: "array";
   items: (Type | TypeName)[];
}

Enum

{
   type: "enum";
   items: string[];
}

Nullable

{
   nullable?: boolean;
}

Assert

{
   assert?: (v: unknown) => asserts v is unknown;
}