pgn-manager 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +100 -1
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1 +1,100 @@
1
- # pgn-manager
1
+ # PGN Manager 📦♟️
2
+
3
+ A powerful TypeScript/JavaScript library for managing chess PGN (Portable Game Notation) files with support for variations and game traversal.
4
+
5
+ [![NPM Package](https://img.shields.io/npm/v/pgn-manager.svg)](https://www.npmjs.com/package/pgn-manager)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
8
+ [![npm downloads](https://img.shields.io/npm/dm/pgn-manager.svg)](https://www.npmjs.com/package/pgn-manager)
9
+ [![Coverage Status](https://coveralls.io/repos/github/username/pgn-manager/badge.svg?branch=main)](https://coveralls.io/github/username/pgn-manager?branch=main)
10
+
11
+
12
+ ## Features ✨
13
+ - Parse PGN strings into manageable objects
14
+ - Navigate through main lines and variations
15
+ - Access FEN positions for any move
16
+ - Handle game headers
17
+ - Traverse moves forward and backward
18
+ - Full TypeScript support
19
+
20
+ ## Installation 🚀
21
+
22
+ ```console
23
+ npm install pgn-manager
24
+ ```
25
+
26
+ ## Usage 💻
27
+
28
+ ```typescript
29
+ import PGNManager from 'pgn-manager';
30
+
31
+ // Initialize with a PGN string
32
+ const pgn = `1. e4 e5 2. Nf3 Nc6 (2... d6 3. d4) 3. Bb5 *`;
33
+ const manager = new PGNManager(pgn);
34
+
35
+ // Get the first move
36
+ const firstMove = manager.getFirstMove();
37
+
38
+ // Navigate through moves
39
+ const nextMove = manager.nextMove(firstMove);
40
+ const prevMove = manager.previousMove(nextMove);
41
+
42
+ // Get FEN position for a move
43
+ const fen = manager.getMoveFen(firstMove);
44
+
45
+ // Access game headers
46
+ const headers = manager.headers;
47
+ ```
48
+
49
+ ## API Reference 📚
50
+
51
+ ### Constructor
52
+ - `new PGNManager(pgn: string)`: Creates a new PGN manager instance
53
+
54
+ ### Properties
55
+ - `pgn`: Get the raw PGN string
56
+ - `parsedPGN`: Get the parsed PGN object
57
+ - `headers`: Get game headers array
58
+
59
+ ### Methods
60
+ - `getMove(moveNumber: number)`: Get move by number
61
+ - `getMoveNumber(move: Move)`: Get number for a move
62
+ - `nextMove(move: Move)`: Get next move in the sequence
63
+ - `previousMove(move: Move)`: Get previous move
64
+ - `hasNextMove(move: Move)`: Check if move has a next move
65
+ - `getFirstMove()`: Get the first move of the game
66
+ - `getLastMove()`: Get the last move of the game
67
+ - `getMoveFen(move: Move)`: Get FEN position after move
68
+ - `getParentRav(move: Move)`: Get parent variation for move
69
+
70
+ ## Examples 🎯
71
+
72
+ ### Traversing Main Line
73
+
74
+ ```typescript
75
+ const manager = new PGNManager("1. e4 e5 2. Nf3 Nc6 3. Bb5 *");
76
+ let move = manager.getFirstMove();
77
+
78
+ while (manager.hasNextMove(move)) {
79
+ console.log(move.move);
80
+ move = manager.nextMove(move);
81
+ }
82
+ ```
83
+
84
+ ### Working with Variations
85
+
86
+ ```typescript
87
+ const manager = new PGNManager("1. e4 e5 2. Nf3 Nc6 (2... d6 3. d4) 3. Bb5 *");
88
+ const move = manager.getMove(2); // Get second move
89
+ const variation = manager.getParentRav(move);
90
+
91
+ if (variation) {
92
+ console.log("Move is part of a variation!");
93
+ }
94
+ ```
95
+
96
+ ## Contributing 🤝
97
+ Contributions are welcome! Feel free to submit issues and pull requests.
98
+
99
+ ## License 📄
100
+ MIT License - feel free to use this in your projects!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgn-manager",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Libraray built on top of chess.js and pgn-parser to load and process PGN files in typescript.",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index",
@@ -18,9 +18,7 @@
18
18
  "keywords": [
19
19
  "Chess",
20
20
  "PGN",
21
- "Portal",
22
- "Game",
23
- "Notation"
21
+ "Portal Game Notation"
24
22
  ],
25
23
  "author": "Harsh Kumar <hadron43@yahoo.com>",
26
24
  "license": "MIT",
@@ -28,9 +26,11 @@
28
26
  "url": "https://github.com/hadron43/pgn-manager/issues"
29
27
  },
30
28
  "homepage": "https://github.com/hadron43/pgn-manager#readme",
31
- "devDependencies": {
29
+ "dependencies": {
32
30
  "chess.js": "0.12.0",
33
- "pgn-parser": "2.1.0",
31
+ "pgn-parser": "2.1.0"
32
+ },
33
+ "devDependencies": {
34
34
  "typescript": "4.5.2"
35
35
  },
36
36
  "files": [