@canboat/canboatjs 1.26.2 → 1.26.3
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.
- package/lib/fromPgn.js +14 -10
- package/package.json +1 -1
package/lib/fromPgn.js
CHANGED
|
@@ -738,17 +738,21 @@ function readVariableLengthField(options, pgn, field, bs) {
|
|
|
738
738
|
* length and thus that the field number is exactly one byte earlier.
|
|
739
739
|
*/
|
|
740
740
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
741
|
+
try {
|
|
742
|
+
var refField = getField(pgn.fields.PGN, bs.view.buffer[bs.byteIndex-1]-1, pgn)
|
|
743
|
+
|
|
744
|
+
if ( refField ) {
|
|
745
|
+
var bits = (refField.BitLength + 7) & ~7; // Round # of bits in field refField up to complete bytes: 1->8, 7->8, 8->8 etc.
|
|
746
|
+
let res = readField(options, false, pgn, refField, bs)
|
|
747
|
+
|
|
748
|
+
if ( bits > refField.BitLength ) {
|
|
749
|
+
bs.readBits(bits - refField.BitLength, false)
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return res
|
|
749
753
|
}
|
|
750
|
-
|
|
751
|
-
|
|
754
|
+
} catch ( error ) {
|
|
755
|
+
debug(error)
|
|
752
756
|
}
|
|
753
757
|
}
|
|
754
758
|
|