1- # @chess-openings/eco .json
1+ # eco.json (Published as @chess-openings/eco .json)
22
33[ ![ npm version] ( https://badge.fury.io/js/%40chess-openings%2Feco.json.svg )] ( https://www.npmjs.com/package/@chess-openings/eco.json )
44[ ![ npm downloads] ( https://img.shields.io/npm/dm/@chess-openings/eco.json.svg )] ( https://www.npmjs.com/package/@chess-openings/eco.json )
@@ -36,19 +36,14 @@ import { openingBook, findOpening, getFromTos } from "@chess-openings/eco.json";
3636const openings = await openingBook ();
3737
3838// Look up an opening by FEN
39- const opening = findOpening (
40- openings ,
41- " rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1" ,
42- );
39+ const opening = findOpening (openings , " rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1" );
4340
4441console .log (opening ?.name ); // "King's Pawn Opening"
4542console .log (opening ?.eco ); // "B00"
4643console .log (opening ?.moves ); // "1. e4"
4744
4845// Get next and previous positions
49- const { next, from } = await getFromTos (
50- " rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1" ,
51- );
46+ const { next, from } = await getFromTos (" rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1" );
5247
5348console .log (next [0 ]?.name ); // "Sicilian Defense"
5449console .log (from [0 ]?.name ); // "Starting Position"
@@ -96,11 +91,7 @@ const openings = await openingBook();
9691Looks up an opening by FEN with automatic position-only fallback.
9792
9893``` typescript
99- import {
100- findOpening ,
101- getPositionBook ,
102- openingBook ,
103- } from " @chess-openings/eco.json" ;
94+ import { findOpening , getPositionBook , openingBook } from " @chess-openings/eco.json" ;
10495
10596const openings = await openingBook ();
10697const posBook = getPositionBook (openings );
@@ -124,11 +115,7 @@ This function tries to find an opening match at the current position. If no matc
124115
125116``` typescript
126117import { ChessPGN } from " @chess-pgn/chess-pgn" ;
127- import {
128- openingBook ,
129- lookupByMoves ,
130- getPositionBook ,
131- } from " @chess-openings/eco.json" ;
118+ import { openingBook , lookupByMoves , getPositionBook } from " @chess-openings/eco.json" ;
132119
133120const chess = new ChessPGN ();
134121chess .loadPgn (" 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6" );
@@ -173,9 +160,7 @@ Compatible libraries: chess.js, @chess-pgn/chess-pgn, and others with similar AP
173160
174161``` typescript
175162// Many moves deep into a game
176- chess .loadPgn (
177- " 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Na5" ,
178- );
163+ chess .loadPgn (" 1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Na5" );
179164
180165const result = lookupByMoves (chess , openings , { maxMovesBack: 10 });
181166
@@ -220,10 +205,7 @@ console.log(`Found ${caroKann.length} variations`);
220205Returns all openings for an ECO category (A, B, C, D, or E).
221206
222207``` typescript
223- import {
224- getOpeningsByEcoCategory ,
225- openingBook ,
226- } from " @chess-openings/eco.json" ;
208+ import { getOpeningsByEcoCategory , openingBook } from " @chess-openings/eco.json" ;
227209
228210// Get all semi-open games (category B)
229211const semiOpen = await getOpeningsByEcoCategory (" B" );
0 commit comments