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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mahjong-helper

v0.1.2

Published

### 简介

Downloads

8

Readme

mahjong-helper

简介

这个项目是用来辅助自己进行日麻练习的,程序可以分析当前手牌的向听数,以及不同切牌选择之间的进张期望.

API

  1. 读取手牌: parse(code:string)=> { handTiles : Tile[], fuluTiles : Tile[] } 将手牌通过简码的形式转化为对象.万条筒字的简码后缀分别为 m,s,p,z. 比如 1m 代表一万,456p 代表 456 筒.1234567z 分别代表东西南北白发中.

  2. 压缩手牌: encode(Tile[]) => string 将手牌对象压缩为字符串以便于进一步分析.需注意压缩得到的字符串无法通过逆推还原为原有手牌.

  3. 分析向听数: analyse(code:string) => numer 分析当前手牌的向听数.向听数的意思为最快还需多少有效进张才可听牌,其中向听数最大为 8,0 代表听牌,-1 代表荣和.

  4. 给出切牌建议: suggest(hand: Tile[]) => null | Suggest[] 根据当前手牌给出出牌建议,建议的给出逻辑是贪心计算当前局面下的最大进张数,即两面搭子优于单吊边张优于单张.返回 null 说明已经荣和.

  5. 工具函数

    • isWan(tile:Tile) => boolean
    • isSuo(tile:Tile) => boolean
    • isTong(tile:Tile) => boolean
    • isFeng(tile:Tile) => boolean
    • isSanyuan(tile:Tile) => boolean
    • isZi(tile:Tile) => boolean
    • isValidTileTypeAcronym(acronym:string) => boolean
    • isTilesValid(handTiles:Tile[], fuluTiles:Tile[]) => boolean
    • sortTiles(tiles: Tile[]) => Tile[]
    • sortSuggest(suggests:Suggest[]) => Suggest[]