chess-moments 1.4.7 → 1.4.8

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.
@@ -1,3 +1,4 @@
1
+ const { isEmpty } = require('lodash');
1
2
  const fen = require('../fen');
2
3
  const { getBrushCode } = require('../helpers');
3
4
 
@@ -10,7 +11,7 @@ const momentsToPgn = (moments) => {
10
11
  let pgn = '';
11
12
 
12
13
  // Return empty PGN if no moments are provided
13
- if (!Array.isArray(moments) || moments.length === 0) {
14
+ if (isEmpty(moments)) {
14
15
  pgn += `[SetUp "1"]\n`;
15
16
  pgn += `[FEN "${fen.initial}"]\n\n`;
16
17
  pgn += '*';
@@ -20,12 +21,9 @@ const momentsToPgn = (moments) => {
20
21
  let currentDepth = 1;
21
22
  let variationStack = [];
22
23
 
23
- // Check if we need to add FEN headers for non-standard starting position
24
- const initialMoment = moments[0];
25
- if (initialMoment && initialMoment.fen && initialMoment.fen !== fen.initial) {
26
- pgn += `[SetUp "1"]\n`;
27
- pgn += `[FEN "${initialMoment.fen}"]\n\n`;
28
- }
24
+ // Add FEN headers
25
+ pgn += `[SetUp "1"]\n`;
26
+ pgn += `[FEN "${moments[0].fen}"]\n\n`;
29
27
 
30
28
  for (let i = 0; i < moments.length; i++) {
31
29
  const moment = moments[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chess-moments",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "PGN parser that transforms PGN files into chess \"moments\"",
5
5
  "main": "index.js",
6
6
  "files": [