From b562c34ed382ab94cfcaf141c64e54b25e62f430 Mon Sep 17 00:00:00 2001 From: davemarco <83603688+davemarco@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:54:23 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> Co-authored-by: Junhao Liao --- new-log-viewer/src/services/decoders/JsonlDecoder/index.ts | 7 +++---- new-log-viewer/src/typings/logs.ts | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts b/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts index b597c98c..b1a54f4e 100644 --- a/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts +++ b/new-log-viewer/src/services/decoders/JsonlDecoder/index.ts @@ -73,7 +73,7 @@ class JsonlDecoder implements Decoder { build (): LogEventCount { this.#deserialize(); - const numInvalidEvents = Array.from(this.#invalidLogEventIdxToRawLine.keys()).length; + const numInvalidEvents = this.#invalidLogEventIdxToRawLine.size; return { numValidEvents: this.#logEvents.length - numInvalidEvents, @@ -106,9 +106,8 @@ class JsonlDecoder implements Decoder { const results: DecodeResultType[] = []; for (let i = beginIdx; i < endIdx; i++) { - // Explicit cast since typescript thinks `#filteredLogEventMap[i]` - // can be undefined, but it shouldn't be since we performed a bounds check at the - // beginning of the method. + // Explicit cast since typescript thinks `#filteredLogEventMap[i]` can be undefined, but + // it shouldn't be since we performed a bounds check at the beginning of the method. const logEventIdx: number = (useFilter && null !== this.#filteredLogEventMap) ? (this.#filteredLogEventMap[i] as number) : i; diff --git a/new-log-viewer/src/typings/logs.ts b/new-log-viewer/src/typings/logs.ts index 17b381b7..97ce1e25 100644 --- a/new-log-viewer/src/typings/logs.ts +++ b/new-log-viewer/src/typings/logs.ts @@ -16,14 +16,14 @@ enum LOG_LEVEL { type LogLevelFilter = Nullable; -const INVALID_TIMESTAMP_VALUE = 0; - interface JsonLogEvent { timestamp: Dayjs, level: LOG_LEVEL, fields: JsonObject } +const INVALID_TIMESTAMP_VALUE = 0; + export type { JsonLogEvent, LogLevelFilter,