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

hand-ranker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hand-ranker

a poker hand ranking module

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

hand-ranker

Returns the best possible 5-card poker hand from an array of N >= 5 cards.

installation

npm install hand-ranker

usage

A card is represented by an object with properties 's' and 'v', where 's' describes the suit (s = spade, h = heart, c = club, d = diamond) and 'v' describes the value (1 = ace, 13 = king).

bestHand(cards) - returns a results object with the best 5-card hand (sorted), a string describing the hand, an integer hand value (0 = high card, 8 = straight flush)

var ranker = require('hand-ranker');

var cards = [
  { s: 's', v: 10 },
  { s: 'c', v: 1 },
  { s: 's', v: 13 },
  { s: 's', v: 1 },
  { s: 'd', v: 1 },
  { s: 's', v: 12 },
  { s: 's', v: 11 }
];

var result = ranker.bestHand(cards);

/*
result:
{
  hand: [
    { s: 's', v: 10 },
    { s: 's', v: 11 },
    { s: 's', v: 12 },
    { s: 's', v: 13 },
    { s: 's', v: 1 }
  ],
  type: 'straight flush',
  val: 8
}
*/

license

MIT

Keywords

FAQs

Package last updated on 17 Jul 2017

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