From b53e3c69a3c4489d7b517766400d6ab4b2ac2d47 Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Sat, 30 Dec 2023 00:27:27 -0500 Subject: [PATCH] Simplify JSON trailing comment regular expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not a huge change, but when it comes to regular expressions, every bit of simplification helps—at least when it comes to readability, if not performance. --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index ace065a..311aba9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -214,7 +214,7 @@ export function stripJsonComments(jsonStr) { } result += curChar } - return result.replaceAll(/,(\s*)([\]}])/g, ' $1$2') + return result.replaceAll(/,(\s*[\]}])/g, ' $1') } /**