tarot-deck-utility
v1.0.0
Published
`tarot-deck-utility` is a TypeScript/JavaScript library for working with tarot cards. It provides utilities for creating, shuffling, cutting, and drawing cards from a tarot deck. This library is designed to be modular and easy to use for tarot-related app
Readme
Tarot
tarot-deck-utility is a TypeScript/JavaScript library for working with tarot cards. It provides utilities for creating, shuffling, cutting, and drawing cards from a tarot deck. This library is designed to be modular and easy to use for tarot-related applications.
Features
- Full 78-card tarot deck implementation.
- Support for Major and Minor Arcana cards.
- Utilities for shuffling and cutting the deck.
- Draw cards with upright or reversed positions.
- TypeScript support for strong typing and better developer experience.
Installation
Install the library via npm:
npm install tarot-deck-utilityUsage
Importing the Library
import { Deck } from 'Tarot';Creating a Deck
const deck = new Deck();Shuffling the Deck
deck.shuffle();Cutting the Deck
deck.cut(); // Random cut
deck.cut(10); // Cut at a specific indexDrawing Cards
const drawnCards = deck.draw(3); // Draw 3 cards
drawnCards.forEach(card => console.log(card.toString()));Resetting the Deck
deck.reset(); // Resets the deck to its original stateCard Class
The Card class represents an individual tarot card.
Properties
face: The face value of the card (e.g., "The Fool", "A").suit: The suit of the card (e.g., "Cups", "Swords") NOTE: major arcana will have the suit "Major Arcana"position: The position of the card (Upright,Reversed).
Methods
toString(): Returns a string representation of the card.toEmojis(): Returns an emoji representation of the card.
Utilities
Shuffle
The Shuffle utility provides a method to shuffle an array of cards.
import { Shuffle } from 'Tarot'';
Shuffle.shuffle(deck.cards);Cut
The Cut utility provides a method to cut an array of cards at a specific index.
import { Cut } from 'Tarot'';
const cutDeck = Cut.cut(deck.cards, 10);