From d47032132161c67902156c7c16ced1f236c1e853 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Wed, 13 May 2026 15:54:54 +0700 Subject: [PATCH] style: format packetFilter --- src/packetFilter.ts | 54 ++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/packetFilter.ts b/src/packetFilter.ts index d87ab69..aa698d9 100644 --- a/src/packetFilter.ts +++ b/src/packetFilter.ts @@ -5,33 +5,37 @@ import { Transform, TransformCallback } from "stream"; * Packet yang terlalu kecil kemungkinan gagal didekripsi oleh Discord */ export class PacketFilter extends Transform { - private minPacketSize: number; - private filteredCount: number = 0; - private totalCount: number = 0; + private minPacketSize: number; + private filteredCount: number = 0; + private totalCount: number = 0; - constructor(minPacketSize: number = 10) { - super(); - this.minPacketSize = minPacketSize; + constructor(minPacketSize: number = 10) { + super(); + this.minPacketSize = minPacketSize; + } + + _transform( + chunk: Buffer, + encoding: string, + callback: TransformCallback, + ): void { + this.totalCount++; + + // Filter packet yang terlalu kecil + if (chunk.length >= this.minPacketSize) { + this.push(chunk); + } else { + this.filteredCount++; + if (this.filteredCount % 10 === 0) { + // console.log(`[packet-filter] Filtered ${this.filteredCount} small packets (size < ${this.minPacketSize} bytes)`); + } } - _transform(chunk: Buffer, encoding: string, callback: TransformCallback): void { - this.totalCount++; - - // Filter packet yang terlalu kecil - if (chunk.length >= this.minPacketSize) { - this.push(chunk); - } else { - this.filteredCount++; - if (this.filteredCount % 10 === 0) { - // console.log(`[packet-filter] Filtered ${this.filteredCount} small packets (size < ${this.minPacketSize} bytes)`); - } - } - - callback(); - } + callback(); + } - _flush(callback: TransformCallback): void { - // console.log(`[packet-filter] Total packets: ${this.totalCount}, filtered: ${this.filteredCount}, passed: ${this.totalCount - this.filteredCount}`); - callback(); - } + _flush(callback: TransformCallback): void { + // console.log(`[packet-filter] Total packets: ${this.totalCount}, filtered: ${this.filteredCount}, passed: ${this.totalCount - this.filteredCount}`); + callback(); + } }