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 · Deck tools

cardFromCodefunction

The card a character names, or null for one that names none — a kept string is read, never trusted.

Import it

import { cardFromCode } from "@johnmorrisdotca/toranpu/deck";

Definition

function cardFromCode(code: string): Card | null

Parameters

NameTypeDescription
codestring

The encoded card or game state.

Returns

Card | null

The card a character names, or null for one that names none — a kept string is read, never trusted.

Examples

import { cardCode, cardFromCode } from "@johnmorrisdotca/toranpu/deck";

const card = { suit: "spades", rank: 1 } as const;
console.log(cardFromCode(cardCode(card)));
{ suit: 'spades', rank: 1 }

What it prints (run when this page was built)

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