Skip to content

draw

draw<T>(pile, n?): T[]

Defined in: cards/card.ts:145

Removes n cards from the end of pile (the top of the deck) and returns them in the order drawn, so draw(['2S', '3S', '4S'], 2) returns ['4S', '3S'] and leaves ['2S']. Mutates pile in place, so it works on the Mutative draft in an action:

state.hands[seat].push(...draw(state.deck, 2));

Throws a RangeError when the pile has fewer than n cards.

T = "2S" | "2H" | "2D" | "2C" | "3S" | "3H" | "3D" | "3C" | "4S" | "4H" | "4D" | "4C" | "5S" | "5H" | "5D" | "5C" | "6S" | "6H" | "6D" | "6C" | "7S" | "7H" | "7D" | "7C" | "8S" | "8H" | "8D" | "8C" | "9S" | "9H" | "9D" | "9C" | "AS" | "AH" | "AD" | "AC" | "TS" | "TH" | "TD" | "TC" | "JS" | "JH" | "JD" | "JC" | "QS" | "QH" | "QD" | "QC" | "KS" | "KH" | "KD" | "KC"

T[]

number = 1

T[]