Skip to content

Commit

Permalink
fix: handle canboat FieldType name change to FIELDTYPE_LOOKUP (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored Oct 15, 2023
1 parent c23b1f9 commit 9fa380d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/fromPgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) {
}
if ( options.checkForInvalidFields !== false && max !== 'undefined' &&
field.FieldType !== 'LOOKUP' &&
field.FieldType !== 'FIELDTYPE_LOOKUP' &&
field.BitLength > 1 &&
max - value <= 0 ) {
//console.log(`Bad field ${field.Name} ${max - value}`)
Expand All @@ -633,7 +634,8 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) {
value = Number.parseFloat(value.toFixed(precision))
}

if (field.FieldType === 'LOOKUP' &&
if ((field.FieldType === 'LOOKUP' ||
field.FieldType === 'FIELDTYPE_LOOKUP') &&
runPostProcessor &&
(_.isUndefined(options.resolveEnums) ||
options.resolveEnums)) {
Expand Down
3 changes: 2 additions & 1 deletion lib/toPgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ function writeField(bs, pgn_number, field, data, value, fields, bitLength) {
}
} else if ( type && fieldTypeMappers[type] ) {
value = fieldTypeMappers[type](field, value)
} else if (field.FieldType === 'LOOKUP' && _.isString(value)) {
} else if ((field.FieldType === 'LOOKUP' ||
field.FieldType === 'FIELDTYPE_LOOKUP') && _.isString(value)) {
if (!(field.Id === "timeStamp" && value < 60)) {
value = lookup(field, value)
}
Expand Down

0 comments on commit 9fa380d

Please sign in to comment.