CardGameCodectype
A game's keeping: encode writes it as text, decode reads it back or gives null.
Import it
import type { CardGameCodec } from "@johnmorrisdotca/toranpu";
Definition
type CardGameCodec<S> = {
encode: (game: S) => string;
decode: (text: string | null) => S | null;
};
Members
| Name | Type | Description |
|---|---|---|
encode | (game: S) => string | |
decode | (text: string | null) => S | null |
Examples
import type { CardGameCodec, GameOf } from "@johnmorrisdotca/toranpu";
import { rulesFor } from "@johnmorrisdotca/toranpu";
const value: CardGameCodec<GameOf<"hearts">> = rulesFor("hearts");
console.log(typeof value.decode);functionWhat it prints (run when this page was built)