2.2.3 • Published 10 months ago

@jackstenglein/chess v2.2.3

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.3

10 months ago

2.2.1

10 months ago

2.2.0

10 months ago

2.2.2

10 months ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.7

1 year ago

2.1.0

1 year ago

1.0.64

1 year ago

1.0.63

1 year ago

1.0.62

1 year ago

1.0.60

1 year ago

1.0.59

1 year ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 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

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago