diff --git a/dist/bert.js b/dist/bert.js index 19305cf..9d3ba64 100644 --- a/dist/bert.js +++ b/dist/bert.js @@ -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), }; diff --git a/src/bert.ts b/src/bert.ts index 7d0b61b..c249cdb 100644 --- a/src/bert.ts +++ b/src/bert.ts @@ -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), };