0.8.3 • Published 1 year ago

chess-moments v0.8.3

Weekly downloads
5
License
MIT
Repository
github
Last release
1 year ago

Chess moments

This package is a javascript PGN parser that transforms PGN files into chess "moments". In its simplest form, a chess "moment" has a chess move and its corresponding FEN.

Chess moments includes comments, shapes, variations, special characters, everything that you need in order to correctly display a chess game in javascript.

Installation

npm i chess-moments
# or
yarn add chess-moments

API

The API returns various arrays of objects (chess moments). These chese moments have specific keys like move, fen, depth and index

The first chess moment is always an object without the move key. It only has fen, depth, index and optionally comment or shapes.

{
  "move": "e4",
  "fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
  "comment": "Opening the queen and the bishop",
  "depth": 1
}

.flat()

Returns a single level deep array of chess moments. The depth key delimits between variants and subvariants played in the chess game.

.tree()

Returns a two level deep array of chess moments. The first level splits between variants and subvariants played in the chess game.

JSON output

The basic PGN file 1. e4 e5 * will generated the following chess moments in JSON format:

[
  {
    "fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
    "depth": 1,
    "index": 0
  },
  {
    "move": "e4",
    "fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
    "depth": 1,
    "index": 1
  },
  {
    "move": "e5",
    "fen": "rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2",
    "depth": 1,
    "index": 2
  }
]
0.8.3

1 year ago

0.8.2

2 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.5.0

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.3.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago