Card Dealer
A robust card-dealing JavaScript Class written in TypeScript
Features
Use any card deck with the
Dealer
classShuffle deck into a random order
Draw cards for use
Discard cards without revealing them
Cut the deck
Included Decks
Standard 52 Playing Cards
Uno
Installation
npm
yarn
Usage
TypeScript
JavaScript
API
const dealer = new Dealer(cardArray)
Dealer()
takes a deck of cards to use for a game & places it on the draw pile.
dealer.shuffle()
Randomizes the dealer's draw pile order using the Fisher-Yates shuffle algorithm.
dealer.cut(index)
Cuts the deck at the specified position in the deck, moving the bottom half to the top of the draw pile.
dealer.draw(count)
Returns the number of cards requested from the draw pile for use in the game.
dealer.discard(count)
Moves the number of cards specified from the draw pile to the discard pile without revealing the value to the game.
dealer.reset()
Resets the draw & discard piles to the default deck position.
dealer.remainingCards()
Returns a count for the remaining cards in the draw pile.
Last updated