mistake buffer slice

This commit is contained in:
Moon Man 2024-01-28 12:31:24 -05:00
parent f0660ca220
commit 35c2763c31
2 changed files with 4 additions and 4 deletions

4
dist/bert.js vendored
View File

@ -282,12 +282,12 @@ export class Bert {
};
decode_binary = (buffer) => {
const size = this.bytesToInt(buffer, 4, true);
buffer = Buffer.from(buffer, 4);
buffer = buffer.subarray(4);
const bin = Buffer.alloc(size);
buffer.copy(bin, 0, 0, size);
return {
value: this.convention === Lang.ELIXIR && this.allBinariesAsString
? bin.toString()
? bin.toString("utf-8")
: bin,
rest: buffer.subarray(size),
};

View File

@ -328,13 +328,13 @@ export class Bert {
decode_binary = (buffer: Buffer) => {
const size = this.bytesToInt(buffer, 4, true);
buffer = Buffer.from(buffer, 4);
buffer = buffer.subarray(4);
const bin = Buffer.alloc(size);
buffer.copy(bin, 0, 0, size);
return {
value:
this.convention === Lang.ELIXIR && this.allBinariesAsString
? bin.toString()
? bin.toString("utf-8")
: bin,
rest: buffer.subarray(size),
};