yo35 / kokopu

A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.
https://www.npmjs.com/package/kokopu
GNU Lesser General Public License v3.0
27 stars 5 forks source link

Wrong behavior of `Database#game(..)` with invalid indexes #24

Closed yo35 closed 2 years ago

yo35 commented 2 years ago
var pgn = ' ... '; // let's assume this is a valid PGN string with 2 games.
var database = kokopu.pgnRead(pgn);
var gameIndex = 3; // invalid index since database contains only 2 games, at indexes 0 and 1 respectively
database.game(gameIndex); // WRONG BEHAVIOR -> returns the first game, instead of throwing an exception
yo35 commented 2 years ago

Fixed in 2.4.1