From aec60654676597d696f2b21a8bd36ef5be49dbe3 Mon Sep 17 00:00:00 2001 From: Ayoub-Mabrouk Date: Thu, 31 Oct 2024 01:49:43 +0100 Subject: [PATCH] Refactor firstchar function for conciseness and modern syntax - Replaced var with const for improved variable management - Used optional chaining for a more concise return statement - Enhanced readability while preserving functionality --- lib/types/json.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/types/json.js b/lib/types/json.js index 30bf8cab..bc2de839 100644 --- a/lib/types/json.js +++ b/lib/types/json.js @@ -189,11 +189,8 @@ function createStrictSyntaxError (str, char) { */ function firstchar (str) { - var match = FIRST_CHAR_REGEXP.exec(str) - - return match - ? match[1] - : undefined + const match = FIRST_CHAR_REGEXP.exec(str) + return match?.[1] } /**