1.0.3 • Published 6 years ago

ultimate-deck v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Deck

Deck is a basic JavaScript implementation of a deck of 52 cards. An interface is provided to draw and shuffle cards within the deck.

Installation

Install with NPM: npm install ultimate-deck

Creating & Using a Deck

Import the Deck

const { Deck } = require('ultimate-deck');

Configure the deck

To create a deck object, instantiate it from the Deck constructor:

const myDeck = new Deck();

The cards will be initially inserted in order. To randomize the order of the cards, call .shuffle:

myDeck.shuffle();

Draw Cards from the Deck

Remove the card from the top of the deck, return it as an object having the keys "rank", "suit", "value" and "stringfy" and add it back at the bottom of the deck:

// Draw a single card
const drawnCard = myDeck.draw();
// Get the string representation of the card
drawnCard.stringfy;
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago