poker-hand-verifier
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

CI

Poker Hand Verifier

Provides a verifier for a poker hand of 5 cards.

It works on browser and server side.

Installation

Using npm with Node.js >= 12:

npm install poker-hand-verifier

Using unpkg CDN:

<script src="https://unpkg.com/poker-hand-verifier/dist/poker-hand-verifier.min.js"></script>

How to use

You can use CommonJS or ESM syntax.

import { verificateHand } from 'poker-hand-verifier';

const myCards = [
  { number: '4', suit: 'S' },
  { number: '5', suit: 'H' },
  { number: '8', suit: 'D' },
  { number: '7', suit: 'S' },
  { number: '6', suit: 'C' },
];

console.log(verificateHand(myCards));
// {
//   cards: ['4S', '5H', '8D', '7S', '6C'],
//   description: 'Straight: 4 - 8',
//   type: 'straight'
// }

Using with CDN, verificateHand() will be available as a method of a global variable called 'pokerHandVerifier'.

<script src="https://unpkg.com/poker-hand-verifier/dist/poker-hand-verifier.min.js"></script>

<script>
  const myCards = [
    { number: '10', suit: 'S' },
    { number: 'K', suit: 'S' },
    { number: 'J', suit: 'S' },
    { number: 'Q', suit: 'S' },
    { number: 'A', suit: 'S' },
  ];

  console.log(pokerHandVerifier.verificateHand(myCards));
  // {
  //   cards: ['10S', 'KH', 'JD', 'QS', 'AC'],
  //   description: 'Royal Flush (S)',
  //   type: 'royal-flush'
  // }
</script>

Package Sidebar

Install

npm i poker-hand-verifier

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

30.3 kB

Total Files

7

Last publish

Collaborators

  • hdoc