2.2.12 • Published 10 months ago

@jackstenglein/chess v2.2.12

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@jackstenglein/chess

@jackstenglein/chess is a TypeScript chess library based on chess.js and cm-chess. It provides PGN/FEN loading; move generation/validation; variations, including reordering and promoting; tracking the current move and seeking through a PGN; PGN header values; NAGs; comments; check/checkmate/stalemate detection; null moves; and more.

This library is used to power the ChessDojo annotation editor and tactics tests.

Installation

Run the following command to install the most recent version from NPM:

npm install @jackstenglein/chess

Importing

import { Chess } from '@jackstenglein/chess';

Example Code

The code below plays a random game of chess:

import { Chess } from '@jackstenglein/chess';

const chess = new Chess();

while (!chess.isGameOver()) {
    const moves = chess.moves();
    const move = moves[Math.floor(Math.random() * moves.length)];
    chess.move(move);
}

console.log(chess.renderPgn());

Also see the tests for further examples.

User Interface

This is a headless library and does not include user interface elements. ChessDojo has successfully integrated this library with Lichess Chessground.

Features

It has a similar API to chess.js and provides much of the same functionality. However, it also offers additional features:

  • Handles variations in addition to the mainline PGN
  • Handles Chessbase-style null moves (Z0)
  • Handles NAGs and comments
  • Keeps track of the "current move" and allows seeking/traversing through the PGN
  • Allows fetching/setting known PGN headers, as well as arbitrary PGN headers
  • Allows fetching/setting known PGN commands, as well as arbitrary PGN commands
  • Allows subscribing to specific events and receiving notifications in a callback
2.2.5

1 year ago

2.2.4

1 year ago

2.2.11

11 months ago

2.2.7

1 year ago

2.2.12

10 months ago

2.2.6

1 year ago

2.2.10

1 year ago

2.2.9

1 year ago

2.2.8

1 year ago

2.2.3

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.2

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.7

2 years ago

2.1.0

2 years ago

1.0.64

2 years ago

1.0.63

2 years ago

1.0.62

2 years ago

1.0.60

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.57

2 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.40

3 years ago

1.0.44

3 years ago

1.0.43

3 years ago

1.0.41

3 years ago

1.0.48

3 years ago

1.0.47

3 years ago

1.0.46

3 years ago

1.0.45

3 years ago

1.0.49

3 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.55

2 years ago

1.0.54

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.56

2 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago