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

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

NameTypeDescription
deckreadonly Card[]

The deck in its current order; the input is left unchanged.

countnumber

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)

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