deckofcardsapi-client

    1.1.0 • Public • Published

    deckofcardsapi-client

    Promise-based NodeJS Client for https://deckofcardsapi.com. Supporting default instance (https://deckofcardsapi.com) or a custom one.

    Usage

    Here is a basic exemple, for more detailed informations, see wiki.

    const  DeckBuilder  =  require("deckofcardsapi-client");
     
    try {
     
        //Create a new shuffled deck of 52 cards
        const  deck  =  await  new  DeckBuilder().standardDeck();
        
        //Draw 5 cards from deck
        const hand = await deck.draw(5);
     
        //Shuffle or reshuffle the deck
        await deck.shuffle();
     
        //Create a new pile nammed "discard"
        const discardPile = await deck.getPile("discard");
     
        //Add hand to discard pile
        await discardPile.add(hand);
     
        //List pile content
        console.log(await discardPile.list());
        
     
    } catch (error) {
     
        console.log(error);
     
    }

    Using custom instance

    In order to use your custom instance, include this code.

    const api = require("deckofcardsapi-client").api;
    api.sethost("https://exemple.com");

    Install

    npm i deckofcardsapi-client

    DownloadsWeekly Downloads

    2

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    10.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • piigo