Socket
Socket
Sign inDemoInstall

deckofcards-api

Package Overview
Dependencies
36
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    deckofcards-api

Unofficial wrapper for Deck of Cards API


Version published
Maintainers
1
Install size
1.79 MB
Created

Readme

Source

deckofcards-api

Unofficial Node.js Library for interacting with the Deck of Cards API. (https://deckofcardsapi.com/)

--

Install

npm install --save deckofcards-api

--

API Methods

deck(options)

Get a deck of cards with an optional options object.

const cards = require('deckofcards-api')

// get a deck with the default options
cards.deck()

// configure deck options
const options = {
    shuffle: boolean // default: false
    deck_count: int  // default: 1
    cards: Array     // All 52 cards
}
// get a deck with custom options
cards.deck(options)

reshuffle(deckId)

Reshuffle a deck of cards by id.

const cards = require('deckofcards-api')

const deck = cards.deck()
cards.reshuffle(deck.deck_id)

draw(deckId)

Draw cards.

const cards = require('deckofcards-api')

const deck = cards.deck()

const count = { count: 2 } // required
cards.draw(deck.deck_id, count)

pile(deckId, pileName).add(cards)

Add cards to a pile.

const cards = require('deckofcards-api')

const deck = cards.deck()

const
    pileName = 'discards',  // required
    cards = [ 'AS', 'KS', 'QS', JS', '10S' ]  // required
cards.pile(deckId, pileName).add(cards)

pile(deckId, pileName).draw(cards)

Draw cards from a pile by card names, count or bottom.

const cards = require('deckofcards-api')

const deck = cards.deck()

const
    pileName = 'discards',              // required
    cards = { cards: [ 'AS', 'KS' ] }   // required
cards.pile(deckId, pileName).draw(cards)

// OR

const
    pileName = 'discards',  // required
    count = { count: 2 }    // required
cards.pile(deckId, pileName).draw(count)

// OR

const
    pileName = 'discards',  // required
    bottom = { bottom: true }    // required
cards.pile(deckId, pileName).draw(bottom)

pile(deckId, pileName).shuffle()

Shuffle the pile.

const cards = require('deckofcards-api')

const deck = cards.deck()

const pileName = 'discards' // required
cards.pile(deckId, pileName).shuffle()

pile(deckId, pileName).show()

Show cards in the pile.

const cards = require('deckofcards-api')

const deck = cards.deck()

const pileName = 'discards' // required
cards.pile(deckId, pileName).show()

Keywords

FAQs

Last updated on 22 Mar 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc