
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
chess-ts-lib
Advanced tools
chess-ts-lib is a TypeScript-based library that provides a complete object-oriented architecture to manage a chess game, including players, board state, piece logic, movements, turns, castling, promotion, check and checkmate validations, and more.
npm
npm install chess-ts-lib
pnpm
pnpm add chess-ts-lib
Piece (abstract class): Base class for all pieces. Each piece implements its own movement logic.ChessBoard: Main class that handles piece movement, turn changes, checkmate detection, and game logic.Game: High-level class for starting the game and managing players.BoardMovements, BoardStateManager, TurnManager: Utility classes for managing movements, board state, and player turns.CastlingManager: Manages castling permissions and execution.BoardValidations: Static validation methods.PieceFactory, PieceDirections: Utilities for piece instantiation and direction control.import { Game, Player, PieceColor } from "chess-ts-lib";
const game = new Game(console.log);
game.start();
game.manager.addPlayer(new Player("Alice"));
game.manager.addPlayer(new Player("Bob"));
if (game.arePlayersReady) {
game.move([6, 4], [4, 4]); // Example: white pawn e2 to e4
}
import { Game, createFreshBoard, PieceFactory } from "chess-ts-lib";
const customBoard = createFreshBoard();
customBoard[0][0] = PieceFactory.create("rook", "black");
customBoard[7][7] = PieceFactory.create("rook", "white");
const game = new Game(console.log);
game.start(customBoard);
Use the notifier function to receive logs or game notifications.
const game = new Game((msg) => console.log("Event:", msg));
You can validate board state, simulate castling or checkmate, and create custom boards using:
import { createFreshBoard, cloneBoard } from "chess-ts-lib";
Run unit tests to ensure functionality:
pnpm test
isInBounds: Validates if a position is within board limits.isCellEmpty, isCellCaptured, isCellBlocked: Helpers to check cell state.logMovement: Logs a movement.cloneBoard: Returns a deep copy of the board.PieceFactory: Instantiates specific pieces.Below is a simplified UML diagram of the library's architecture:
+-------------------+
| Game |
+-------------------+
|
v
+-------------------+
| ChessBoard |
+-------------------+
|
v
+-------------------+
| Piece |
+-------------------+
|
+------+-------+
| | |
v v v
Pawn Rook Bishop
The code is modular and open for extension. You can:
To add a new piece, extend the Piece class and implement its movement logic:
import { Piece } from "chess-ts-lib";
class CustomPiece extends Piece {
getAvailableMoves() {
// Custom movement logic
}
}
Special moves are handled automatically by the library if the board state is valid.
Yes, the library is designed to be UI-agnostic and can be integrated with any frontend framework.
MIT License
Pull requests and ideas are welcome! Please ensure your code follows the existing style and includes tests.
FAQs
Typescript base utilities for a chess game.
We found that chess-ts-lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.