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

poker-hands

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poker-hands - npm Package Compare versions

Comparing version 0.0.2 to 1.0.0

readme.md

35

index.js

@@ -38,11 +38,2 @@ // In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:

var sampleHands = [
['5H 5C 6S 7S KD', '2C 3S 8S 8D TD'],
['5D 8C 9S JS AC', '2C 5C 7D 8S QH'],
['2D 9C AS AH AC', '3D 6D 7D TD QD'],
['4D 6S 9H QH QC', '3D 6D 7H QD QS'],
['2H 2D 4C 4D 4S', '3C 3D 3S 9S 9D'],
];
var should = require('should');
var _ = require('lodash');

@@ -61,12 +52,5 @@

var hasPair = _.curry(hasAKind)(2);
hasPair(sampleHands[0][0]).should.eql('5');
hasPair(sampleHands[0][1]).should.eql('8');
var hasThreeOfAKind = _.curry(hasAKind)(3);
hasThreeOfAKind(sampleHands[2][0]).should.eql('A');
var hasFourOfAKind = _.curry(hasAKind)(4);
hasFourOfAKind('9D 9S KH 9H 9C').should.eql('9');
var cardOrder = ['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'];

@@ -90,5 +74,2 @@

}
hasTwoPairs('3H 9C 9S 2D 3D').should.eql(['9', '3']);
hasTwoPairs('7S 8H 8C KH KS').should.eql(['K', '8']);
sampleHands[0].map(hasTwoPairs).should.eql([undefined, undefined]);

@@ -100,4 +81,2 @@ function highestCard(hand) {

}
highestCard(sampleHands[1][0])[0].should.eql('A');
highestCard(sampleHands[1][1])[0].should.eql('Q');

@@ -107,8 +86,3 @@ function hasFlush(hand) {

}
hasFlush(sampleHands[2][1]).should.eql('D');
hasPair(sampleHands[3][0]).should.eql('Q');
hasPair(sampleHands[3][1]).should.eql('Q');
highestCard(sampleHands[3][0])[0].should.eql('9');
highestCard(sampleHands[3][1])[0].should.eql('7');

@@ -121,4 +95,2 @@ function hasFullHouse(hand) {

}
hasFullHouse(sampleHands[4][0]).should.eql('4');
hasFullHouse(sampleHands[4][1]).should.eql('3');

@@ -133,3 +105,2 @@ function hasStraight(hand) {

}
hasStraight('8D 6C 5S 7H 4S').should.eql('8');

@@ -141,3 +112,2 @@ function hasStraightFlush(hand) {

}
hasStraightFlush('4H 3H 6H 5H 7H').should.eql('7');

@@ -147,3 +117,2 @@ function hasRoyalFlush(hand) {

}
hasRoyalFlush('AD KD JD QD TD').should.eql(true);

@@ -168,5 +137,2 @@ var bestHands = [

}
sampleHands.map(function (round) {
return round.map(getHandStrength);
}).should.eql([[8, 8], [9, 9], [6, 4], [8, 8], [3, 3]]);

@@ -181,3 +147,2 @@ function judgeWinner(players) {

}
sampleHands.map(judgeWinner).should.eql([1, 0, 1, 0, 0]);

@@ -184,0 +149,0 @@ module.exports = {

6

package.json
{
"name": "poker-hands",
"version": "0.0.2",
"description": "Quickly evalute poker hands",
"version": "1.0.0",
"description": "Quickly evaluate poker hands",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -30,2 +30,8 @@ /*global describe,it*/

it('.hasTwoPair(hand) should detect two pairs', function () {
poker.hasTwoPairs('3H 9C 9S 2D 3D').should.eql(['9', '3']);
poker.hasTwoPairs('7S 8H 8C KH KS').should.eql(['K', '8']);
sampleHands[0].map(poker.hasTwoPairs).should.eql([undefined, undefined]);
});
it('.hasThreeOfAKind(hand) should detect a three of a kind', function () {

@@ -35,12 +41,6 @@ poker.hasThreeOfAKind(sampleHands[2][0]).should.eql('A');

it('.hasFourOfAKind(hand) should detect a four of a kind', function () {
poker.hasFourOfAKind('9D 9S KH 9H 9C').should.eql('9');
it('.hasStraight(hand) should detect a straight', function () {
poker.hasStraight('8D 6C 5S 7H 4S').should.eql('8');
});
it('.hasTwoPair(hand) should detect two pairs', function () {
poker.hasTwoPairs('3H 9C 9S 2D 3D').should.eql(['9', '3']);
poker.hasTwoPairs('7S 8H 8C KH KS').should.eql(['K', '8']);
sampleHands[0].map(poker.hasTwoPairs).should.eql([undefined, undefined]);
});
it('.hasFlush(hand) should detect a flush', function () {

@@ -55,4 +55,4 @@ poker.hasFlush(sampleHands[2][1]).should.eql('D');

it('.hasStraight(hand) should detect a straight', function () {
poker.hasStraight('8D 6C 5S 7H 4S').should.eql('8');
it('.hasFourOfAKind(hand) should detect a four of a kind', function () {
poker.hasFourOfAKind('9D 9S KH 9H 9C').should.eql('9');
});

@@ -59,0 +59,0 @@

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