mistake buffer slice
This commit is contained in:
parent
f0660ca220
commit
35c2763c31
|
@ -282,12 +282,12 @@ export class Bert {
|
||||||
};
|
};
|
||||||
decode_binary = (buffer) => {
|
decode_binary = (buffer) => {
|
||||||
const size = this.bytesToInt(buffer, 4, true);
|
const size = this.bytesToInt(buffer, 4, true);
|
||||||
buffer = Buffer.from(buffer, 4);
|
buffer = buffer.subarray(4);
|
||||||
const bin = Buffer.alloc(size);
|
const bin = Buffer.alloc(size);
|
||||||
buffer.copy(bin, 0, 0, size);
|
buffer.copy(bin, 0, 0, size);
|
||||||
return {
|
return {
|
||||||
value: this.convention === Lang.ELIXIR && this.allBinariesAsString
|
value: this.convention === Lang.ELIXIR && this.allBinariesAsString
|
||||||
? bin.toString()
|
? bin.toString("utf-8")
|
||||||
: bin,
|
: bin,
|
||||||
rest: buffer.subarray(size),
|
rest: buffer.subarray(size),
|
||||||
};
|
};
|
||||||
|
|
|
@ -328,13 +328,13 @@ export class Bert {
|
||||||
|
|
||||||
decode_binary = (buffer: Buffer) => {
|
decode_binary = (buffer: Buffer) => {
|
||||||
const size = this.bytesToInt(buffer, 4, true);
|
const size = this.bytesToInt(buffer, 4, true);
|
||||||
buffer = Buffer.from(buffer, 4);
|
buffer = buffer.subarray(4);
|
||||||
const bin = Buffer.alloc(size);
|
const bin = Buffer.alloc(size);
|
||||||
buffer.copy(bin, 0, 0, size);
|
buffer.copy(bin, 0, 0, size);
|
||||||
return {
|
return {
|
||||||
value:
|
value:
|
||||||
this.convention === Lang.ELIXIR && this.allBinariesAsString
|
this.convention === Lang.ELIXIR && this.allBinariesAsString
|
||||||
? bin.toString()
|
? bin.toString("utf-8")
|
||||||
: bin,
|
: bin,
|
||||||
rest: buffer.subarray(size),
|
rest: buffer.subarray(size),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue