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

card-dealer-cli

v1.0.3

Published

CLI utility for interacting with a deck of cards: pick a random card or deal a hand for a card game

Downloads

17

Readme

Card Dealer CLI

CLI utility for interacting with a deck of cards. You can draw a random card or cards from various types of decks (standard, euchre, pinochle, or canasta). You can also deal a hand for several card games: blackjack, poker, euchre, pinochle, canasta, gin, or rummy.

Installation

npm install -g card-dealer-cli

CLI Usage

There are two commands available: pick-a-card and deal-a-hand

Usage: card-dealer [options] [command]

Options:
  -p, --perfect-shuffle        Should all randomness be removed when shuffling the deck? (default:false)
  -t, --shuffle-times <times>  How many times should we shuffle the deck? (default: 7)
  --cut [Y/n]                  Do you want to cut the deck after shuffling?
  -h, --help                   display help for command

Commands:
  pick-a-card [options]        Pick a random card or cards from a deck
  deal-a-hand [options]        Deal a hand for one of several types of card games
  help [command]               display help for command

pick-a-card

Pick a random card (or multiple cards) from a deck of cards.

pick-a-card cli in action

(This is the default command, so it will run if you don't specify another command)

Usage: card-dealer pick-a-card [options]

Pick a random card or cards from a deck

Options:
  -d, --deck <deck-type>  What type of deck should we use (choices: "standard", "double", "euchre", "canasta", "pinochle", default: "standard")
  -c, --count <number>    How many cards should be chosen? (default: 1)
  --top                   Should the card be pulled from the top of the deck, rather than at a random point in the deck? (default: false)
  -h, --help              display help for command

Examples

Pick a random card from a standard 52 card deck:

card-dealer

Cut the deck after shuffling without being prompted

card-dealer pick-a-card --cut

Do not shuffle or cut the deck and pick a card off the top of the deck. (This will not be random at all).

card-dealer pick-a-card --shuffle-times 0 --cut n --top

Pick two random cards from a canata deck:

card-dealer pick-a-card --deck canasta --count 2

deal-a-hand

Deal the initial hand for several types of cards games: blackjack, poker, euchre, pinochle, canasta, gin or rummy.

deal-a-hand cli in use

Usage: card-dealer deal-a-hand [options]

Deal a hand for one of several types of card games

Options:
  -g, --game <game-type>  What card game should we deal a hand for? (choices: "blackjack", "poker", "euchre", "pinochle", "canasta", "gin", "rummy")
  -h, --help              display help for command

Examples

Deal hand, being prompted for what game

card-dealer deal-a-hand

Deal a game of Texas hold 'em poker

card-dealer deal-a-hand --game poker

Deal a game Euchre without shuffling, only cutting the deck once

card-dealer deal-a-hand --game euchre --shuffle-times 0 --cut

Importing libs

In addition to the CLI utility, you can also import the underlying classes and objects for use in your own application.

npm install card-dealer-cli

Usage

import { StandardDeck, CanastaDeck } from 'card-dealer-cli'

const deck = new StandardDeck()
const canastaDeck = new CanastaDeck()

console.log(deck.count) # => 52
console.log(canastaDeck.count) # => 108

# Shuffle the deck three times
deck.riffleShuffle(3)
# Cut the deck
deck.cut()

const hands = deck.dealHands({ cardsPerHand: 5, numberOfHands: 3 })

console.log(hands[0].showCards()) # => ♠️ J   ♣️ 2   ♣️ 5   ♥ 3   ♦ 2

See the BaseDeck definition for available functions on deck objects and in deck.ts for the types of decks available. Look in the lib directory for defintions of other objects such as Card and Hand