npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@piigo/playingcards

v1.0.2

Published

Playing Cards

Downloads

3

Readme

@piigo/playingcards

Playing Cards package with support for most commons deck types and piles.

NPM Version

Install

npm i @piigo/playingcards
yarn add @piigo/playingcards

Supported Deck Types

Currently, the lib only supports the following deck types :

  • standard (52 cards, without jokers)
  • standardWithJokers (standard deck with 2 jokers)
  • standard32 (32 cards deck without jokers)
  • standard32WithJokers (34 cards deck with jokers)
  • blackjack
  • tarot
  • rummy
  • uno
  • empty (no cards in deck)
  • custom with this you can pass an array of strings representing the cards you want to use.

Usage

Creating a deck


const deck = Deck.builder()	// Get a new instance of DeckBuilder
	.unshuffled()		// By default the deck is created and shuffled, this tells the deck builder to not shuffle the deck
	.standardWithJokers()	// The type of deck you want to play with, defaults to a standard deck if not supplied, see supported deck types
	.create();

Using a deck


const deck = Deck.builder().create();

// Draw a card
deck.draw();

// Draw multiple cards
deck.draw(4);

// Draw n cards from the bottom of the deck
deck.drawBottom(n);

// Add cards to the top of the deck
deck.add(["Cards array to add"]);

// Add cards to the bottom of the deck
deck.addBottom(["Cards array to add"]);

// Shuffle the deck
deck.shuffle();

// Reset the deck
deck.reset(shouldTheDeckBeShuffled)

// See if the deck is shuffled or not
deck.isShuffled();

// Get how many cards remains in the deck
deck.remaining();

// Get or create a new pile of cards in the deck (can represent a hand, discard pile, etc...)
deck.getPile("pileName");

// Get the cards array used by the deck, you should normally not have to use this except for logging purposes
deck.getCards();

Using a Pile


const pile = Deck.builder().create().getPile("discard");

// Draw a card
pile.draw();

// Draw multiple cards
pile.draw(4);

// Draw n cards from the bottom of the pile
pile.drawBottom(n);

// Add cards to the top of the pile
pile.add(["Cards array to add"]);

// Add cards to the bottom of the pile
pile.addBottom(["Cards array to add"]);

// Shuffle the pile
pile.shuffle();

// See if the pile is shuffled or not
pile.isShuffled();

// Get how many cards remains in the pile
pile.remaining();

// Get the cards array used by the pile, you should normally not have to use this except for logging purposes
pile.getCards();

License

MIT