Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winning-hand

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winning-hand

A simple package for determining a winning poker hand given 5-card hands

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Poker Hand Evaluation Functions

This code provides several functions to evaluate poker hands. Each function checks for a specific hand combination and returns a Boolean value indicating whether the hand contains that combination or not.

Functions

hasStraight(hand)

Checks if the given hand contains a straight, which is a sequence of five cards in consecutive order.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a straight, false otherwise.

hasOfAKind(hand)

Checks if the given hand contains a set of cards with the same value, also known as "of a kind."

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Number: The highest count of cards with the same value in the hand.

hasFullHouse(hand)

Checks if the given hand contains a full house, which consists of three cards of one value and two cards of another value.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a full house, false otherwise.

hasFlush(hand)

Checks if the given hand contains a flush, which is a set of five cards of the same suit.

  • Parameters:

    • hand (Array): An array of card values representing a poker hand.
  • Returns:

    • Boolean: true if the hand contains a flush, false otherwise.

Usage

The provided functions can be used to evaluate poker hands by passing an array of card values representing the hand to the respective function.

Example usage:

const hand = ['AH', '2H', '3H', '4H', '5H'];

console.log(hasStraight(hand)); // Output: true
console.log(hasOfAKind(hand)); // Output: 1
console.log(hasFullHouse(hand)); // Output: false
console.log(hasFlush(hand)); // Output: true

FAQs

Package last updated on 05 Jul 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc