https://github.com/minofrk/msf-io-ts
Type utilities with io-ts for MSF format.
https://github.com/minofrk/msf-io-ts
io-ts msf typescript xelto
Last synced: about 1 year ago
JSON representation
Type utilities with io-ts for MSF format.
- Host: GitHub
- URL: https://github.com/minofrk/msf-io-ts
- Owner: minofrk
- License: mit
- Created: 2019-05-31T16:00:29.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-04-11T15:45:57.000Z (about 1 year ago)
- Last Synced: 2025-04-11T16:55:46.782Z (about 1 year ago)
- Topics: io-ts, msf, typescript, xelto
- Language: TypeScript
- Size: 304 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@minofrk/msf-io-ts
===============================================================================
[](https://www.npmjs.com/package/@minofrk/msf-io-ts)
[](LICENSE)
[](https://travis-ci.com/minofrk/msf-io-ts)
[](https://codecov.io/gh/minofrk/msf-io-ts)
[MSF 形式](https://github.com/minofrk/mino-seslax-format)を TypeScript で取り扱う上で有用そうな型を [io-ts](https://github.com/gcanti/io-ts) のコーデックとして用意しています。
```typescript
import { Move } from '@minofrk/msf-io-ts';
// ...
const something = JSON.parse(json);
if (!Move.is(something)) {
throw new TypeError();
}
const move: Move = something;
```
その他、有用そうな型エイリアスと関数も用意されています(下記参照)
Install
-------------------------------------------------------------------------------
```
npm install @minofrk/msf-io-ts
```
加えて [io-ts](https://github.com/gcanti/io-ts) と [fp-ts](https://github.com/gcanti/fp-ts) もインストールします(既にあれば不要です)
```
npm install io-ts fp-ts
```
Codecs
-------------------------------------------------------------------------------
### 局面、指し手、棋譜
- `State`
- `Move`
- `LeimMove`
- `OkkeMove`
- `KorMove`
- `EvMove`
- `SedMove`
- `MSFType`
### 駒
- `Arxe`
- `Sorn`
- `Piece`
- `Teems`
- `TurnablePiece`
### その他
- `FalaType` ... 0 以上 2147483647 以下の整数
- `DateTimeString` ... RFC 3339 に準拠した文字列
- `Player`
- `Coordinate` ... 0 以上 6 以下の整数
- `Position`
- `FromTo`
Type aliases
-------------------------------------------------------------------------------
上述したコーデックはそのまま型エイリアスとしても使用できます。
加えて以下の型が用意されています。
- `ReadonlyState`
- `ReadonlyMove`
- `ReadonlyLeimMove`
- `ReadonlyOkkeMove`
- `ReadonlyKorMove`
- `ReadonlyEvMove`
- `ReadonlySedMove`
- `ReadonlyMSFType`
- `ReadonlyPosition`
- `ReadonlyFromTo`
Strict validators
-------------------------------------------------------------------------------
仕様への準拠を完全に検査するための関数です。指し手の検査は `Move.is()` で既に完全なので `isSpecCompliantMove()` はありません。
- `isSpecCompliantState()`
- `isSpecCompliantMSFType()`
License
-------------------------------------------------------------------------------
See [LICENSE](LICENSE)