Skip to main content

parseCompactCardList

Parse concatenated or whitespace-separated cards (AhKh, Ah Kh, 10hKd). Throws on invalid token or duplicate.

Default returns canonical string[]. Pass { outFormat: 'packed' } to get a Uint8Array of deck ids (0..51) for simulators and other CardInput APIs without an extra pack step.

parseCompactCardList(text: string, options?: ParseCompactCardListOptions): string[] | Uint8Array

Import

const poker = require('poker-calculations');

When to use

Use when importing compact hand histories or HUD paste buffers instead of splitting strings yourself. Use packed output when feeding Monte Carlo or strength helpers directly.

How to use

const cards = poker.parseCompactCardList('AhKh QdJc');
console.log(cards); // ['Ah','Kh','Qd','Jc'] canonical forms

const packed = poker.parseCompactCardList('AhKh QdJc', { outFormat: 'packed' });
const equity = poker.simulateHandOutcome(
packed.subarray(0, 2),
packed.subarray(2),
10_000,
42,
1
);

See also

Card notation · Packed card input