Skip to content

Commit

Permalink
Add encode and decode support for unsigned short
Browse files Browse the repository at this point in the history
  • Loading branch information
E-MEDIA\e.brinette committed Jul 8, 2024
1 parent 64d1c1e commit 6ccf30e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ function encodeFieldValue(buffer, value, offset) {
tag('s');
buffer.writeInt16BE(val, offset); offset += 2;
break;
case 'unsignedshort':
case 'uint16':
tag('u');
buffer.writeUInt16BE(val, offset); offset += 2;
case 'int':
case 'int32':
tag('I');
Expand Down Expand Up @@ -282,6 +286,9 @@ function decodeFields(slice) {
case 's':
val = slice.readInt16BE(offset); offset += 2;
break;
case 'u':
val = slice.readUInt16BE(offset); offset += 2;
break;
case 't':
val = slice[offset] != 0; offset++;
break;
Expand Down

0 comments on commit 6ccf30e

Please sign in to comment.