Skip to content

Commit

Permalink
Fixes joshuaferrara#88 for readCString
Browse files Browse the repository at this point in the history
  • Loading branch information
dabbers committed May 26, 2023
1 parent 9d58de6 commit 85cf3da
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions helpers/VDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ var Type = {
End: 8,
};

const needed_methods = [
"readUint8",
"readCString",
"readInt3",
"readUint64",
"readFloat",
]

exports.decode = function(buffer) {
var object = {};
if(typeof(buffer.readUint8) != "function"){
buffer = ByteBuffer.wrap(buffer);

for (let needed_method of needed_methods) {
if (typeof(buffer[needed_method]) != "function") {
buffer = ByteBuffer.wrap(buffer);
break;
}
}

if(buffer.offset != buffer.limit) {
while (true) {
var type = buffer.readUint8();
Expand Down Expand Up @@ -90,4 +103,4 @@ exports.encode = function(object){
buffer.writeByte(Type.End);
buffer.flip();
return buffer;
};
};

0 comments on commit 85cf3da

Please sign in to comment.