UNPKG

fentastic

Version:

Validate and parse Forsyth-Edwards Notation (FEN) used to describe a chess game board position.

31 lines (30 loc) 1.03 kB
import { type Piece } from './parsePieceField.js'; import { type CastlingAvailability } from './parseCastlingAvailability.js'; import { ParseError } from './ParseError.js'; import { InputError } from './validateInputFen.js'; export { type Piece, type CastlingAvailability, ParseError, InputError }; export declare type ParsedFen = { fen: string; valid: true; fields: string[]; piecePlacement: Piece[]; activeColor: string; castlingAvailability: CastlingAvailability | undefined; enPassantTargetSquare: string | undefined; halfmoveClock: number; fullmoveNumber: number; }; export declare type ValidFen = { fen: string; valid: true; }; export declare type InvalidFen = { fen: unknown; valid: false; errors: (ParseError | InputError)[]; }; export declare type Options = { correctWhiteSpace: boolean; }; export declare const validateFen: (inputFen: string) => ValidFen | InvalidFen; export declare const parseFen: (inputFen: string, options?: Options) => ParsedFen | InvalidFen;