@canboat/canboatjs 1.24.3 → 1.24.4

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/lib/toPgn.js +14 -0
  2. package/package.json +1 -1
package/lib/toPgn.js CHANGED
@@ -28,6 +28,8 @@ const { getIndustryCode, getManufacturerCode } = require('./codes')
28
28
  const debug = require('debug')('canboatjs:toPgn')
29
29
 
30
30
  const RES_STRINGLAU = 'ASCII or UNICODE string starting with length and control byte'
31
+ const RES_STRINGLZ = 'ASCII string starting with length byte'
32
+
31
33
 
32
34
  var fieldTypeWriters = {}
33
35
  var fieldTypeMappers = {}
@@ -115,6 +117,7 @@ function toPgn(data) {
115
117
 
116
118
  if ( pgnData.Length != 0xff
117
119
  && fields[fields.length-1].Type != RES_STRINGLAU
120
+ && fields[fields.length-1].Type != RES_STRINGLZ
118
121
  && !pgnData.RepeatingFields ) {
119
122
 
120
123
  var len = lengthsOff[pgnData.PGN] || pgnData.Length
@@ -383,6 +386,17 @@ fieldTypeWriters['ASCII text'] = (pgn, field, value, bs) => {
383
386
  }
384
387
  }
385
388
 
389
+ fieldTypeWriters[RES_STRINGLZ] = (pgn, field, value, bs) => {
390
+ if ( _.isUndefined(value) ) {
391
+ value = ""
392
+ }
393
+ bs.writeUint8(value.length)
394
+ for ( var i = 0; i < value.length; i++ ) {
395
+ bs.writeUint8(value.charCodeAt(i))
396
+ }
397
+ bs.writeUint8(0)
398
+ }
399
+
386
400
  fieldTypeWriters["String with start/stop byte"] = (pgn, field, value, bs) => {
387
401
  if ( _.isUndefined(value) ) {
388
402
  value = ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "1.24.3",
3
+ "version": "1.24.4",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {