Skip to content

Commit

Permalink
Merge pull request #3 from horita-yuya/feature/npm
Browse files Browse the repository at this point in the history
NPM Publish
  • Loading branch information
horita-yuya authored Nov 21, 2024
2 parents 43704c9 + 7eed4f0 commit 9418150
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# mahjong-kun

```shell
npm install mahjong-kun
```

麻雀の点数計算君

```typescript
Expand Down
31 changes: 1 addition & 30 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
import type {
Calculate,
Hand,
HuAll,
WinningStyle,
YakuAll,
YakuChitoitsu,
YakuPinhu,
} from "./types";
import type { Position } from "./types/field";

export type MahjongKun<
HAND extends Hand,
WINNING extends HAND[number],
NAKI extends HAND[number][],
STYLE extends WinningStyle,
POSITION extends Position,
> = Calculate<
YakuAll<HAND, WINNING, NAKI>,
HuAll<HAND, WINNING, NAKI, STYLE>,
STYLE,
POSITION,
YakuChitoitsu<HAND, WINNING> extends [1, 1]
? "chitoitsu"
: STYLE extends "tumo"
? YakuPinhu<HAND, WINNING, NAKI> extends [1]
? "pin-tumo"
: null
: null
>;
export * from "./types"
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{
"name": "mahjong-kun",
"version": "1.0.0",
"main": "index.ts",
"version": "1.5.0",
"author": "[email protected]",
"license": "MIT",
"files": ["dist", "package.json", "README.md"],
"scripts": {
"test": "tsc --noEmit",
"build": "tsc ./index.ts --declaration --outDir ./dist --emitDeclarationOnly"
"build": "tsc ./index.ts --declaration --outDir ./dist --emitDeclarationOnly",
"pub": "yarn build && npm publish --access public"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"esbuild": "^0.24.0",
"typescript": "^5.6.3"
}
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts"
}
}
},
"types": "./dist/index.d.ts"
}
27 changes: 27 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import type {Hand} from "./hand";
import type {WinningStyle} from "./winning";
import type {Position} from "./field";
import type {Calculate} from "./point";
import type {YakuAll, YakuChitoitsu, YakuPinhu} from "./yaku";
import type {HuAll} from "./hu";

export * from "./hand";
export * from "./hu";
export * from "./point";
Expand All @@ -6,3 +13,23 @@ export * from "./tileSet";
export * from "./utilType";
export * from "./winning";
export * from "./yaku";

export type MahjongKun<
HAND extends Hand,
WINNING extends HAND[number],
NAKI extends HAND[number][],
STYLE extends WinningStyle,
POSITION extends Position,
> = Calculate<
YakuAll<HAND, WINNING, NAKI>,
HuAll<HAND, WINNING, NAKI, STYLE>,
STYLE,
POSITION,
YakuChitoitsu<HAND, WINNING> extends [1, 1]
? "chitoitsu"
: STYLE extends "tumo"
? YakuPinhu<HAND, WINNING, NAKI> extends [1]
? "pin-tumo"
: null
: null
>;

0 comments on commit 9418150

Please sign in to comment.