Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Games and state

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

NameTypeDescription
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);
function

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.