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

void57-chess

v1.0.2

Published

TypeScript chess library for standard chess and Chess960 (Fischer Random Chess) - move generation, validation, and game management.

Readme

Chess Library

A TypeScript chess library for standard chess and Chess960 (Fischer Random Chess) with complete move generation, validation, and game management.

Features

  • Full support for standard chess
  • Complete Chess960 (Fischer Random Chess) support with all 960 starting positions
  • Move generation and validation
  • Proper Chess960 castling rules
  • PGN import/export with Chess960 notation
  • Position number mapping (Scharnagl numbering 0-959)
  • Check, checkmate, and stalemate detection
  • Draw conditions (50-move rule, threefold repetition, insufficient material)
  • FEN/X-FEN position handling
  • Extensively tested in Node.js and modern browsers
  • TypeScript with full type definitions

Installation

npm install void57-chess

Quick Start

Random Chess960 Game

import { Chess960 } from 'void57-chess'

// Create a random Chess960 position
const chess = new Chess960()

console.log('Starting position:')
console.log(chess.ascii())

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

if (chess.isCheckmate()) {
  console.log(`Checkmate! ${chess.turn() === 'w' ? 'Black' : 'White'} wins!`)
} else if (chess.isDraw()) {
  console.log('Draw!')
}

console.log(chess.pgn())

Standard Chess

import { Chess } from 'void57-chess'

const chess = new Chess()
chess.move('e4')
chess.move('e5')
console.log(chess.ascii())

Specific Chess960 Position

import { Chess960 } from 'void57-chess'

// Create position 518 (standard chess starting position)
const standardChess = new Chess960(518)

// Create a specific Chess960 position
const position = new Chess960(42)

// Or load from X-FEN
const fromFen = new Chess960(
  'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w HAha - 0 1',
)

API Overview

Creating a Standard Chess Game

import { Chess } from 'void57-chess'

const chess = new Chess()

// Start from a specific position
const chess = new Chess(
  'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1',
)

Creating a Chess960 Game

import { Chess960 } from 'void57-chess'

// Random position (0-959)
const chess = new Chess960()

// Specific position number
const chess = new Chess960(518) // Standard chess is position 518

// From X-FEN string
const chess = new Chess960(
  'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
)

Making Moves

// Move in various notations
chess.move('e4') // Standard algebraic notation
chess.move('Nf3') // Piece moves
chess.move('O-O') // Castling
chess.move({ from: 'e2', to: 'e4' }) // Object notation

// Get legal moves
const moves = chess.moves() // All moves in SAN
const verboseMoves = chess.moves({ verbose: true }) // Detailed move objects
const pieceMoves = chess.moves({ square: 'e2' }) // Moves for specific square

Game State

chess.inCheck() // Is current player in check?
chess.isCheckmate() // Is it checkmate?
chess.isStalemate() // Is it stalemate?
chess.isDraw() // Is it a draw?
chess.isGameOver() // Is game over?
chess.isThreefoldRepetition() // Threefold repetition?
chess.isInsufficientMaterial() // Insufficient material?

Position Management

chess.fen() // Get current position in FEN
chess.ascii() // ASCII board representation
chess.board() // 2D array representation
chess.turn() // Current player ('w' or 'b')
chess.history() // Move history
chess.undo() // Undo last move
chess.reset() // Reset to starting position

PGN Support

// Export to PGN
const pgn = chess.pgn()

// Load from PGN
const chess = new Chess960()
chess.loadPgn(pgn)

Static Methods

// Generate Chess960 position from number
const fen = Chess960.generatePositionFen(518)

// Validate FEN
import { validateFen } from 'void57-chess'
const result = validateFen(fenString)

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Build the library
npm run build

# Format code
npm run format

# Lint code
npm run lint

# Run all checks
npm run check

License

MIT License - Copyright (c) 2026 void-57 (Aniruddha)

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details on how to contribute to this project.

If you have any questions, suggestions, or find any bugs please open an issue. PRs are very welcome too, please read the Contributing Guide first to help make it a smooth process.