chess-moments 1.4.4 → 1.4.6

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.
@@ -13,6 +13,14 @@ const getPrevMoment = (moments, current) => {
13
13
  return moments[0];
14
14
  }
15
15
 
16
+ const prevIndex = moments.indexOf(current) - 1;
17
+ const prevMoments = moments[prevIndex];
18
+
19
+ // If previous moment does not have a move and it's the initial position, return it
20
+ if (!prevMoments?.move && prevMoments.fen === moments[0].fen) {
21
+ return moments[0];
22
+ }
23
+
16
24
  // Split moments until the current index
17
25
  const currentIndex = moments.indexOf(current);
18
26
  const moves = moments.slice(0, currentIndex).filter((m) => m.move);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chess-moments",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "PGN parser that transforms PGN files into chess \"moments\"",
5
5
  "main": "index.js",
6
6
  "files": [