Skip to main content

Card notation

String form

PartValues
Rank29, J, Q, K, A; ten as T or 10 (not both in one card)
Suitc, d, h, s

Examples: Ah, Th, 10c (same card as Tc). After parsing, canonicalCardString always uses T for ten (Th, not 10h).

Helpers: validateCardString, canonicalCardString, parseCompactCardList (default string[], or { outFormat: 'packed' } for Uint8Array).

Packed form (CardInput)

Most card-list APIs also accept CardInput: a Uint8Array (or Node Buffer) of deck ids (Card52, bytes 0..51):

FieldMeaning
Indexrank * 4 + suit
rank0 = 212 = A
suit0 = c, 1 = d, 2 = h, 3 = s

Example: Ah50, Kh48.

Pack strings once, then pass bytes to hot paths (evaluateHandStrength, simulateHandOutcome, decideAction, …):

const { packCards, unpackCards } = require('poker-calculations/encode');
const hole = packCards(['Ah', 'Kh']); // Uint8Array
unpackCards(hole); // ['Ah', 'Kh']

TypeScript: CardInput = string[] | Uint8Array, Card52 = number (see package index.d.ts). Full details: Packed card input.