npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@poker-apprentice/hand-range-notation

v1.0.0

Published

Convert poker hand range notation to and from poker hands

Downloads

55

Readme

Hand Range Notation

Convert poker hand range notation to and from actual poker hands.

Installation

Add @poker-apprentice/hand-range-notation as a dependency.

  • yarn:
    yarn add @poker-apprentice/hand-range-notation
  • npm:
    npm install @poker-apprentice/hand-range-notation --save

Usage

expandNotation

This function is used to parse a string representing a hand range notation. If a hand range notation cannot be parsed, it will throw an InvalidHandRangeNotationError.

// specific suited hands
const hands = expandNotation('AKs');
console.log(hands); // [['As', 'Ks'], ['Ah', 'Kh'], ['Ad', 'Kd'], ['Ac', 'Kc']]

// specific unsuited hands
const hands = expandNotation('AKo');
console.log(hands); // [['As', 'Kh'], ['As', 'Kd'], ['As', 'Kc'], /* ... */]

// specific hands regardless of suitedness
const hands = expandNotation('AK');
console.log(hands); // [['As', 'Ks'], ['As', 'Kh'], ['As', 'Kd'], /* ... */]

// specific hands with specific suits
const hands = expandNotation('AcKd');
console.log(hands); // [['Ac', 'Kd']]

// pocket pairs
const hands = expandNotation('TT');
console.log(hands); // [['Ts', 'Th'], ['Ts', 'Td'], ['Ts', 'Tc'], /* ... */]

// hand ranges
const hands = expandNotation('AKs-A2s');
const hands = expandNotation('KQo-KJo');
const hands = expandNotation('AK-AT');
const hands = expandNotation('99-22');

// hand minimums
const hands = expandNotation('AT+');
const hands = expandNotation('ATs+');
const hands = expandNotation('TT+');

// multiple ranges
const hands = expandNotation('ATs+, 99-22, AA, KQ, KJs, AcTd');

notate

This function is used to generate a hand range notation string representing a collection of hands.

Only two-card Texas Hold'em hands are supported. Providing hands of any other length will result in an InvalidHandError being thrown.

const notation = notate([
  ['As', 'Ks'],
  ['Ah', 'Kh'],
  ['Ad', 'Kd'],
  ['Ac', 'Kc'],
  ['As', 'Qs'],
  ['Ah', 'Qh'],
  ['Ad', 'Qd'],
  ['Ac', 'Qc'],
  ['Js', 'Jh'],
  ['Js', 'Jd'],
  ['Js', 'Jc'],
  ['Jh', 'Jd'],
  ['Jh', 'Jc'],
  ['Jd', 'Jc'],
  ['Ts', 'Th'],
  ['Ts', 'Td'],
  ['Ts', 'Tc'],
  ['Th', 'Td'],
  ['Th', 'Tc'],
  ['Td', 'Tc'],
]);
console.log(notation); // 'JJ-TT,AQs+'

normalizeNotation

This function converts the provided notation into a predictable/deterministic format.

const notation = normalizeNotation('AKs,TT,QAo,AA'));
console.log(notation); // 'AA,TT,AKs,AQo'

const hands = expandNotation('7d2c,3h2s,KQo,AQo,AKo,ATs+,TT+,A2s-A5s');
const notation = notate(hands);
console.log(notation); // 'TT+,ATs+,A5s-A2s,AQo+,KQo,7d2c,3h2s'