New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@hammerhead/deckmanager

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hammerhead/deckmanager

A ready-to-use card deck manager with pile support using Deck of Cards API

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

Deck Manager

A ready-to-use card deck manager with pile support using the Deck of Cards API. Perfect for building card games like Poker, Blackjack, or custom card-based apps.

Features

  • Automatically initializes a new deck on creation
  • Draw cards from the main deck
  • Shuffle the main deck
  • Support for piles (add, draw, shuffle, and list cards in piles)
  • Works with Jokers
  • Ready-to-use in Node.js (Node 18+ or with node-fetch for older versions)

Installation

# If using Node 18+ (fetch is built-in)
npm install deck-manager

# For Node <18
npm install deck-manager node-fetch

Usage

Initialize Deck

import Deck from "deck-manager";

const deck = new Deck(); // auto-initializes a deck

Draw From Main Deck

const { cards, remaining } = await deck.draw(3);
console.log("Drawn cards:", cards);
console.log("Remaining in deck:", remaining);

Shuffle Deck

await deck.shuffle(); // shuffle the main deck

Working With Piles

// Add cards to a pile
await deck.addToPile("player1", cards);

// Draw from a pile
const pileCards = await deck.drawFromPile("player1", 1);
console.log("Card from pile:", pileCards.cards);

// List all cards in a pile
const remainingPile = await deck.listPile("player1");
console.log("Remaining in pile:", remainingPile);

// Shuffle a pile
await deck.shufflePile("player1");

Example: Deal Hands to Multiple Players

const players = ["Alice", "Bob"];

for (let player of players) {
  const { cards } = await deck.draw(5);  // Draw 5 cards for the player
  await deck.addToPile(player, cards);   // Add to player pile
}

// Show each player's hand
for (let player of players) {
  const hand = await deck.listPile(player);
  console.log(`${player}'s hand:`, hand);
}

API

Constructor

new Deck(count = 1, jokers = false, shuffle = true)

Keywords

deck

FAQs

Package last updated on 09 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts