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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tg-poker-engine

v0.0.1

Published

Shared types and Texas Hold'em engine (cards, hand evaluation, NL betting) for Telegram poker apps.

Readme

tg-poker-engine

Shared TypeScript types for a Telegram poker product plus a small Texas Hold’em engine (deck, hand evaluation, and no-limit betting state machine).

Install

npm install tg-poker-engine

Package entry points

| Subpath | Contents | |--------|----------| | tg-poker-engine | Domain types (UserRole, TableStatus, …) and everything from ./tg-poker-engine (re-exported). | | tg-poker-engine/tg-poker-engine | Poker engine only (cards, evaluation, Hold’em). | Both paths resolve to the same compiled modules under dist/.

Card notation

Cards are strings: rank + suit.

  • Ranks: 29, T (ten), J, Q, K, A (ace high = 14 internally).
  • Suits: c clubs, d diamonds, h hearts, s spades.

Example: "Ah" is ace of hearts.

Poker engine API (high level)

Cards

  • fullDeck() — 52 cards in rank/suit order.
  • shuffle(items, rng?) — Fisher–Yates; optional rng (defaults to Math.random).
  • rankOf(card), suitOf(card) — parse a card string.

Hand evaluation

  • scoreFiveCards(cards) — score vector for exactly five cards (straight wheel A–5 handled).
  • bestScoreFrom7(cards) — best five from seven (Hold’em).
  • compareScores(a, b) — lexicographic compare; positive if a wins.
  • describeScore(score) — human-readable label.

Hold’em

  • startHoldemHand({ seats, buttonSeat, smallBlind, bigBlind, handSeq, rng? }) — new hand: blinds, deal, toActSeat set.
  • applyHoldemAction(state, seatIndex, action) — fold / check / call / bet / raise_to; mutates state.
  • holdemPublicSnapshot(state) — table-safe view (optionally revealedHoles, awardedPot when complete).
  • viewerHoleCards(state, seatIndex) — hole cards for one seat.
  • forceFoldPlayer(state, seatIndex) — fold out of turn (e.g. disconnect).
  • nextButtonSeat(occupiedSorted, currentButton) — rotate button among occupied seats.

Client actions (HoldemClientAction):

  • { type: "fold" }
  • { type: "check" } — only when not facing a bet.
  • { type: "call" }
  • { type: "bet", amount } — first aggression on a street (minimum = big blind when maxStreetBet === 0).
  • { type: "raise_to", amount } — total street commitment after the action; must beat current max and satisfy minRaise unless shoving.

Build from source

npm install
npm run build

Output is written to dist/ (CommonJS require / exports, with .d.ts types).

Publishing checklist

  1. Set name in package.json to the scoped name you own on npm (or unscope it).
  2. Set license (default in this repo is UNLICENSED; use MIT or another SPDX id and add a LICENSE file if you open-source it).
  3. Bump version, then run npm publish. Scoped packages default to private on npm; this repo sets publishConfig.access = "public" so a plain npm publish is enough (or use npm publish --access public once if you remove that field). prepublishOnly runs npm run build automatically so dist/ matches sources.
  4. The "files" field limits the tarball to dist/; npm still ships README.md and package.json automatically.

Review notes (correctness & limits)

The public functions are internally consistent: five-card scoring, wheel straight, seven-card best hand, and Hold’em blind / deal order (including heads-up) match usual rules.

Limits you should know before production use:

  1. Single main pot only — there are no side pots. If multiple players are all-in for different amounts, chip accounting is not split into side pots.
  2. No card validationrankOf / evaluation assume valid "[23456789TJQKA][cdhs]" strings; garbage input can yield NaN or nonsense scores.
  3. Mutating stateapplyHoldemAction and related helpers mutate the passed HoldemState. Clone first if you need time-travel or optimistic UI rollback.
  4. Module format — compiled output is CommonJS; modern bundlers and recent Node versions still consume this fine via the exports map; if you need pure ESM-only publishing, adjust tsconfig / package.json "type" separately.

There is no single “incorrect method” in the sense of a wrong signature; the important caveat is side-pot absence for real-money or full tournament logic.

License

See package.json field "license" (set by the package maintainer).