npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chessstate

v1.1.4

Published

A chess game state manager

Readme

ChessState

A chess game state manager that is intended to be variant friendly (eventually).

Download

npm install --save chessstate

Link to NPM page: https://www.npmjs.com/package/chessstate

Using ChessState

let ChessState = require("chessstate")

// Initalize a new game
let game = new ChessState.ChessState()  // Uses default config object

// Execute move "e4" for white.
game.move("e4")

// Execute move "e5" for black.
game.move("e5")

// Print out an ascii representation of the board.
game.printBoard()

Example of usage: https://github.com/NathanTan/ChessStateExample

Initalization

// Defaul config object
const config = {
  gameType: 0, // Standard Chess (Currently only type availible)
  fen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", // Example FEN string of the starting position
  hideOutput: true // Will not output to the console
}

// Example config object
const config = {
  gameType: 0, // Standard Chess (Currently only type availible)
  fen: "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1", // Example FEN string of the boards position after the move "e4"
  hideOutput: true // Will not output to the console
}

Methods

move()

Executes a move.

Parameters:

  • Move: a string representing a chess move. Acceptable forms of moves constist of PGN string, FEN string, or resigning with the string "resign".

Examples:

> game.move("e4") // Move the white pawn to "e4" as the first move of the game
> game.move("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1") // Move the white pawn to "e4" as the first move of the game
> game.move("resign") // White resigns (Provided no player has moved yet)

getStatus()

Returns an object containing the status of the game.

Parameters: None

Example:

> game.getStatus()
{ gameOver: false, turn: null, winner: null }

Output

Standard Chess Grid:

               Black
  ---------------------------------
0 | r | n | b | q | k | b | n | r |
  ---------------------------------
1 | p | p | p | p | p | p | p | p |
  ---------------------------------
2 |   |   |   |   |   |   |   |   |
  ---------------------------------
3 |   |   |   |   |   |   |   |   |
  ---------------------------------
4 |   |   |   |   |   |   |   |   |
  ---------------------------------
5 |   |   |   |   |   |   |   |   |
  ---------------------------------
6 | P | P | P | P | P | P | P | P |
  ---------------------------------
7 | R | N | B | Q | K | B | N | R |
  ---------------------------------
    A   B   C   D   E   F   G   H
               White

Basic Chess Information

What is a FEN string?

A FEN string represents a standard chess board and includes information about the state of the game, including important details such as which player has the next turn, castling availability, En Passant, Halfmoves, and Fullmoves.

What is a PGN string?

A PGN string represents an individual chess move.

Supported Varients

Bughouse

Description:

Bughouse is a 4 player, 2v2 version of chess where 2 seperate games of chess happen simultaneously. But you and your teammate play opposite colors and when you capture a piece on your board, you pass it to your teammate where they can spend a turn placing it on their board.

Varient Usage

When placing a piece on the board that was captured by a teammate, add a tilda to the pgn. Example:

> game.move("e4~")

Use the function "getExtraPieces" to get the extra pieces a player has available to them. Example:

// Get the extra pieces for the first board that white can use
> game.getExtraPieces(0, StandardTurns.white)

Notes

This library has no dependencies.

Base repository location: https://github.com/NathanTan/ChessState