Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
poker-hand-evaluator
Advanced tools
Poker Texas Holdem Hand Evaluator using Cactus Kev's algorithm
Evaluate the score (the lower the better) of a poker hand as described in this post blog : http://suffe.cool/poker/evaluator.html. You can compare two poker hands to find out who wins or if it's a tie.
I've ported some part Cactus Kev's C code : http://suffe.cool/poker/code/
It works on browser side too although the lib is a little heavy ~102 Kb because of the use of lookup tables. But it's robust and really fast. You can evaluate all the cards combinations in few seconds.
Node.js >= 6
npm install --save poker-hand-evaluator
const PokerHand = require('poker-hand-evaluator');
const myPokerHand = new PokerHand('KS KH QC AH AD');
const hisPokerHand = new PokerHand('KD KC AS AH TD')
console.log(myPokerHand.describe());
// { hand: [ 'KS', 'KH', 'QC', 'AH', 'AD' ],
// score: 2468,
// rank: 'TWO_PAIRS' }
console.log(hisPokerHand.describe());
// { hand: [ 'KD', 'KC', 'AS', 'AH', 'TD' ],
// score: 2470,
// rank: 'TWO_PAIRS' }
console.log(myPokerHand.getRank());
// TWO_PAIRS
console.log(hisPokerHand.getRank());
// TWO_PAIRS
console.log(myPokerHand.getScore());
// 2468
console.log(hisPokerHand.getScore());
// 2470
console.log(myPokerHand.toString());
// KS KH QC AH AD
console.log(hisPokerHand.toString());
// KD KC AS AH TD
/**
* return 1 if it's a Win
* return 2 if it's a Loss
* return 3 if it's a Tie
*/
console.log(myPokerHand.compareWith(hisPokerHand));
// 1
Node.js >= 8.5.0 is necessary to run the tests
git clone https://github.com/codeKonami/poker-hand.git
cd poker-hand
# Install dev dependencies (Webpack, babel, Jest ...)
npm install
# Launch an example
npm run dev
npm run test
This command will run the unit tests (through Jest) and will also evaluate the time it takes to evaluate all the combinations. Finally it will display 10 random comparisons.
npm run build
This command generates a pokerhand.min.js file in the dist/
folder to be used on browser. You can try an example of implementation on browser by launching a web server in the root folder.
python -m SimpleHTTPServer
# Now go to http://localhost:8000
FAQs
Poker Texas Holdem Hand Evaluator using Cactus Kev's algorithm
The npm package poker-hand-evaluator receives a total of 506 weekly downloads. As such, poker-hand-evaluator popularity was classified as not popular.
We found that poker-hand-evaluator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.