
Security News
/Company News
Socket Is Sponsoring Composer and Packagist
Socket has joined the new Composer and Packagist sponsorship program as a launch sponsor, supporting the team that keeps PHP's package ecosystem secure.
麻雀アガリ和了形計算
Japanese riichi mahjong hand agari calculation
Install with npm:
# npm i agari
Use in browser:
<script src="https://cdn.jsdelivr.net/npm/agari/index.js"></script>
Usage:
const agari = require('agari')
let hai = [
[3,1,1,3,0,0,0,0,0], //萬子
[3,0,0,0,0,0,0,0,0], //筒子
[3,0,0,0,0,0,0,0,0], //索子
[0,0,0,0,0,0,0] //字牌
]
console.log(agari(hai))
Output:
[
//和了形1
[
'1m', //雀頭
[ '1m', '2m', '3m' ], //順子
[ '1p' ], //刻子
[ '1s' ], //刻子
[ '4m' ] //刻子
],
//和了形2
[
[ '1m' ], //刻子
[ '1p' ], //刻子
[ '1s' ], //刻子
[ '2m', '3m', '4m' ], //順子
'4m' //雀頭
]
]
"m,p,s,z" means "萬子,筒子,索子,字牌"
"1z-7z" means "東南西北白發中"
Check only:
const agari = require('agari')
//check 一般形
agari.check([
[3,1,1,1,2,1,1,1,3],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0]
]) //return true
//check7 七対子形
agari.check7([
[2,0,2,2,2,2,2,0,2],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0]
]) //return true
//check13 国士形
agari.check13([
[1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,1],
[1,1,1,1,2,1,1]
]) //return true
//check all types
agari.checkAll([
[1,1,1,1,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0]
]) //return boolean
FAQs
Japanese riichi mahjong agari calculation
The npm package agari receives a total of 66 weekly downloads. As such, agari popularity was classified as not popular.
We found that agari 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.

Security News
/Company News
Socket has joined the new Composer and Packagist sponsorship program as a launch sponsor, supporting the team that keeps PHP's package ecosystem secure.

Research
/Security News
Benign-looking npm packages split malicious functionality across a dependency chain that deploys a cross-platform RAT targeting Alibaba developers.

Research
/Security News
Two Joyfill npm beta releases contain an import-time implant that uses blockchain transactions to retrieve a remote-access trojan.