Skip to content

Commit

Permalink
chore: tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Dec 1, 2023
1 parent edd4571 commit fc1256e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/packetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export class PacketBuilder {
}

public getPackets(): Buffer[] {
this.#finishBuffer(true)
this.#finishBuffer(false)

this.#finished = true

return this.#completedBuffers
}

#finishBuffer(skipCreateNext?: boolean) {
#finishBuffer(allocNewBuffer = true) {
if (this.#currentPacketFilled === 0 || this.#finished) return

this.#completedBuffers.push(this.#currentPacketBuffer.subarray(0, this.#currentPacketFilled))

if (!skipCreateNext) {
if (allocNewBuffer) {
this.#currentPacketBuffer = Buffer.alloc(this.#maxPacketSize)
this.#currentPacketFilled = 0
}
Expand Down

0 comments on commit fc1256e

Please sign in to comment.