1.4.5 • Published 7 months ago

cards-deck v1.4.5

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

��# Deck Module

The Deck module provides a class for working with a deck of cards. It includes methods for creating a fresh deck and shuffling the deck.

Usage

First, import the Deck class:

import { Deck } from "cards-deck"; 

Creating a Fresh Deck

To create a fresh deck of cards, you can use the freshDeck method provided by the Deck class:

const deck = new Deck();

The freshDeck method generates a new deck of 52 cards, including the standard 4 suits (`&, c&, f&, e&) and 14 values (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, JOKER).

Shuffling the Deck

You can shuffle the deck of cards using the shuffle method:

deck.shuffle();

The shuffle method shuffles the order of the cards using Fisher-Yates algorithm, providing a randomized order.

Example

import { Deck } from "cards-deck";

const deck = new Deck();

// Create a fresh deck
const freshDeck = deck.freshDeck();
console.log("Fresh Deck:", freshDeck);

// Shuffle the deck
deck.shuffle();
console.log("Shuffled Deck:", deck.cards);

License

This module is open-source and available under the MIT License. You are free to use and modify it as needed for your projects.

1.4.5

7 months ago

1.4.4

7 months ago

1.4.3

7 months ago

1.3.3

7 months ago

1.3.2

7 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.2.0

7 months ago

1.1.0

7 months ago

1.0.0

7 months ago