Class DatabaseAbstract

Describe a set of chess games, each of them being represented by a Game object.

Hierarchy

  • Database

Methods

Methods

  • Return the game corresponding to the given index.

    Throws

    InvalidPGN if the corresponding game cannot be parsed, or if the given game index is larger than the number of games in the underlying PGN data.

    Parameters

    • gameIndex: number

      Must be between 0 inclusive and gameCount exclusive.

    Returns Game

  • Number of games in the database.

    Returns number

  • Return an Iterable object allowing to iterate over all the (valid) games within the database.

    Example, to print the ASCII representation of all the games within a database:

    const database = ... ;
    for (const game of database.games()) {
    console.log(game.ascii());
    }

    If the database contains some games that cannot be parsed (i.e. games for which the method game would throw a InvalidPGN exception), those games are ignored during the iteration. WARNING: for this reason, the number of games returned by the iterator may be lower than gameCount.

    Returns Iterable<Game>

Generated using TypeDoc