kokopu
Version:
A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.
104 lines (103 loc) • 4.78 kB
TypeScript
/*!
* -------------------------------------------------------------------------- *
* *
* Kokopu - A JavaScript/TypeScript chess library. *
* <https://www.npmjs.com/package/kokopu> *
* Copyright (C) 2018-2025 Yoann Le Montagner <yo35 -at- melix.net> *
* *
* Kokopu is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* Kokopu is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General *
* Public License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* -------------------------------------------------------------------------- */
import { Color, Piece, ColoredPiece, File, Rank, Square, SquareCouple, Castle, Castle960, Coordinates, GameResult, GameVariant } from './base_types';
/**
* Whether the given value represents a valid {@link Color} or not.
*/
export declare function isColor(value: unknown): value is Color;
/**
* Whether the given value represents a valid {@link Piece} or not.
*/
export declare function isPiece(value: unknown): value is Piece;
/**
* Whether the given value represents a valid {@link ColoredPiece} or not.
*/
export declare function isColoredPiece(value: unknown): value is ColoredPiece;
/**
* Whether the given value represents a valid {@link File} or not.
*/
export declare function isFile(value: unknown): value is File;
/**
* Whether the given value represents a valid {@link Rank} or not.
*/
export declare function isRank(value: unknown): value is Rank;
/**
* Whether the given value represents a valid {@link Square} or not.
*/
export declare function isSquare(value: unknown): value is Square;
/**
* Whether the given value represents a valid {@link SquareCouple} or not.
*/
export declare function isSquareCouple(value: unknown): value is SquareCouple;
/**
* Whether the given value represents a valid {@link Castle} or not.
*/
export declare function isCastle(value: unknown): value is Castle;
/**
* Whether the given value represents a valid {@link Castle960} or not.
*/
export declare function isCastle960(value: unknown): value is Castle960;
/**
* Whether the given value represents a valid {@link GameResult} or not.
*/
export declare function isGameResult(value: unknown): value is GameResult;
/**
* Whether the given value represents a valid {@link GameVariant} or not.
*/
export declare function isGameVariant(value: unknown): value is GameVariant;
/**
* Execute the given callback on each of the 64 squares.
*/
export declare function forEachSquare(callback: (square: Square) => void): void;
/**
* Return the color of a square.
*/
export declare function squareColor(square: Square): Color;
/**
* Return the coordinates of a square.
*/
export declare function squareToCoordinates(square: Square): Coordinates;
/**
* Return the square corresponding to the given coordinates.
*/
export declare function coordinatesToSquare(file: number, rank: number): Square;
/**
* Return the square corresponding to the given coordinates.
*/
export declare function coordinatesToSquare(coordinates: Coordinates): Square;
/**
* Change white to black, and black to white.
*/
export declare function oppositeColor(color: Color): Color;
/**
* Whether the given variant has a canonical start position or not.
*/
export declare function variantWithCanonicalStartPosition(variant: GameVariant): boolean;
/**
* Return the human-readable symbol for the given [NAG](https://en.wikipedia.org/wiki/Numeric_Annotation_Glyphs).
*/
export declare function nagSymbol(nag: number): string;
/**
* Whether the given string represents a valid [ECO code](https://en.wikipedia.org/wiki/List_of_chess_openings) or not.
*/
export declare function isValidECO(eco: string): boolean;