Skip to content

jakubgereg/cards-unicode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cards Unicode

Displays all cards in unicode.

Install

yarn add cards-unicode

or

npm install cards-unicode

Usage

let cardsUnicode = require("cards-unicode");

API

getAll()

Example

let cardUnicode = cardsUnicode.getAll().map(({ cardDisplay }) => {
  return cardDisplay;
});

console.log(...cardUnicode);

//console.log: A♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠ 8♠ 9♠ 10♠ J♠ Q♠ K♠ A♥ 2♥ 3♥ 4♥ 5♥ 6♥ 7♥ 8♥ 9♥ 10♥ J♥ Q♥ K♥ A♦ 2♦ 3♦ 4♦ 5♦ 6♦ 7♦ 8♦ 9♦ 10♦ J♦ Q♦ K♦ A♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣ 8♣ 9♣ 10♣ J♣ Q♣ K♣

getAllBySuit(suit)

Example

console.log(cardsUnicode.getAllBySuit("Heart"));
//You can use symbols instead "♠" "♥" "♦" "♣"
console.log(cardsUnicode.getAllBySuit("♦"));

//console.log:
//  { id: 15,
//     cardName: 'Two of Hearts',
//     cardDisplay: '2♥',
//     suitSymbol: '♥',
//     cardNumber: '2' },
//  { id: 16,
//     cardName: 'Three of Hearts',
//     cardDisplay: '3♥',
//     suitSymbol: '♥',
//     cardNumber: '3' },
//...other

getById(cardId)

Example

console.log(getById(52));

//console.log:
// { id: 52,
//   cardName: 'King of Clubs',
//   cardDisplay: 'K♣',
//   suitSymbol: '♣',
//   cardNumber: 'K' }

getAllByNumber(number)

Example

console.log(getAllByNumber("K"));

//console.log:
// [ { id: 13,
//     cardName: 'King of Spades',
//     cardDisplay: 'K♠',
//     suitSymbol: '♠',
//     cardNumber: 'K' },
//   { id: 26,
//     cardName: 'King of Hearts',
//     cardDisplay: 'K♥',
//     suitSymbol: '♥',
//     cardNumber: 'K' },
//...other

getByNumberAndSuit(number, suit)

Example

console.log(getByNumberAndSuit("J", "♣"));

//console.log:
// { id: 50,
//   cardName: 'Jack of Clubs',
//   cardDisplay: 'J♣',
//   suitSymbol: '♣',
//   cardNumber: 'J' }

About

Cards representation in Unicode

Resources

Stars

Watchers

Forks

Packages

No packages published