Skip to content

Commit 63f2090

Browse files
committed
Fill buffer to 4 bytes if needed inside convertBinaryToInteger function
1 parent ffcb419 commit 63f2090

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ Header.prototype.parseFieldSubRecord = function(buffer) {
5757
};
5858

5959
Header.prototype.convertBinaryToInteger = function(buffer) {
60-
return buffer.readInt32LE(0, true);
60+
const fillerBytesCount = 4 - buffer.length;
61+
const fillerBytes = Buffer.alloc(fillerBytesCount, 0);
62+
const filledBuffer = Buffer.concat([buffer, fillerBytesCount]);
63+
64+
return filledBuffer.readInt32LE(0);
6165
};
6266

6367

0 commit comments

Comments
 (0)