takefunction
Take count from the top: what was taken, and what is left.
Import it
import { take } from "@johnmorrisdotca/toranpu/deck";
Definition
function take(deck: readonly Card[], count: number): { taken: Card[]; rest: Card[]; }
Parameters
| Name | Type | Description |
|---|---|---|
deck | readonly Card[] | The deck in its current order; the input is left unchanged. |
count | number | The requested number of cards, sounds or layout positions. |
Returns
{ taken: Card[]; rest: Card[]; }
Take count from the top: what was taken, and what is left.
Examples
import { shuffledDeck, take } from "@johnmorrisdotca/toranpu/deck";
console.log(take(shuffledDeck(42), 5).taken);[
{ suit: 'clubs', rank: 3 },
{ suit: 'clubs', rank: 9 },
{ suit: 'hearts', rank: 2 },
{ suit: 'hearts', rank: 13 },
{ suit: 'clubs', rank: 13 }
]What it prints (run when this page was built)