New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@botpoker/rank-hands

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

@botpoker/rank-hands

Sort poker hands by texas hold'em ranking

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@botpoker/rank-hands

You can install @botpoker/rank-hands via npm:

npm i @botpoker/rank-hands

Intro

If you are making some sort of poker game, chances are that sooner or later you want to know in a group of cards combination what is the best.

This is exactly what @botpoker/rank-hands is for.

@botpoker/rank-hands expects as input a list of cards combination. A cards combination is a list of five cards object (check brunoscopelliti/poker-deck).

It sorts the input by the strength of the combination. The original index of each entry is added as index property on each entry.

const sortByRank = require("@botpoker/rank-hands");

const sortedCombs = sortByRank([
  [{ rank: "A", type: "C" },
  { rank: "9", type: "H" }, { rank: "J", type: "C" }, { rank: "8", type: "C" }, { rank: "2", type: "C" }]
  [{ rank: "Q", type: "C" }, { rank: "3", type: "D" }, { rank: "3", type: "S" }, { rank: "J", type: "C" }, { rank: "4", type: "C" }],
]);

sortedCombs;

// [
//   [
//     { rank: "Q", type: "C" },
//     { rank: "3", type: "D" },
//     { rank: "3", type: "S" },
//     { rank: "J", type: "C" },
//     { rank: "4", type: "C" },
//     index: 0,
//     rank: {
//       strength: 1,
//       rank: "3",
//       kickers: [
//         "Q",
//         "J",
//         "4",
//       ]
//     }
//   ],
//   [
//     { rank: "A", type: "C" },
//     { rank: "9", type: "H" },
//     { rank: "J", type: "C" },
//     { rank: "8", type: "C" },
//     { rank: "2", type: "C" },
//     index: 0,
//     rank: {
//       strength: 0,
//       rank: "A",
//       kickers: [
//         "J", 
//         "9", 
//         "8",
//         "2",
//       ]
//     }
//   ]
// ]

@botpoker/rank-hands uses @botpoker/hand to evaluate the strength of a combination.

@botpoker/hand also handles ex-equo. In case of ex-equo, the objects have also an exequo property.

Keywords

FAQs

Package last updated on 02 May 2021

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