From db1f140075f6162047385ac4930b0ba2890e0c3d Mon Sep 17 00:00:00 2001 From: Simon Holloway Date: Wed, 10 Jan 2024 19:10:11 +0000 Subject: [PATCH 1/2] refactor(json): prepare for `noUncheckedIndexedAccess` --- json/concatenated_json_parse_stream.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/concatenated_json_parse_stream.ts b/json/concatenated_json_parse_stream.ts index 3d41fba574f2..cfea3747ce23 100644 --- a/json/concatenated_json_parse_stream.ts +++ b/json/concatenated_json_parse_stream.ts @@ -4,8 +4,8 @@ import type { JsonValue, ParseStreamOptions } from "./common.ts"; import { parse } from "./_common.ts"; const blank = new Set(" \t\r\n"); -function isBlankChar(char: string) { - return blank.has(char); +function isBlankChar(char: string | undefined) { + return char !== undefined && blank.has(char); } const primitives = new Map( From 0d1b5206c5ec1327811e35250d85d098d5f00c9d Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Thu, 11 Jan 2024 11:56:59 +1100 Subject: [PATCH 2/2] tweak --- json/concatenated_json_parse_stream.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/json/concatenated_json_parse_stream.ts b/json/concatenated_json_parse_stream.ts index cfea3747ce23..5437476244bb 100644 --- a/json/concatenated_json_parse_stream.ts +++ b/json/concatenated_json_parse_stream.ts @@ -3,9 +3,8 @@ import { toTransformStream } from "../streams/to_transform_stream.ts"; import type { JsonValue, ParseStreamOptions } from "./common.ts"; import { parse } from "./_common.ts"; -const blank = new Set(" \t\r\n"); function isBlankChar(char: string | undefined) { - return char !== undefined && blank.has(char); + return char !== undefined && [" ", "\t", "\r", "\n"].includes(char); } const primitives = new Map(