diff --git a/gramjs/extensions/BinaryWriter.ts b/gramjs/extensions/BinaryWriter.ts index a19a1520..2d8df7b6 100644 --- a/gramjs/extensions/BinaryWriter.ts +++ b/gramjs/extensions/BinaryWriter.ts @@ -1,15 +1,15 @@ export class BinaryWriter { - private _stream: Buffer; + private readonly _buffers: Buffer[]; constructor(stream: Buffer) { - this._stream = stream; + this._buffers = [stream]; } write(buffer: Buffer) { - this._stream = Buffer.concat([this._stream, buffer]); + this._buffers.push(buffer); } - getValue() { - return this._stream; + getValue(): Buffer { + return Buffer.concat(this._buffers); } }