From 7f12cf439b28318340e71de67884c7f18bd90608 Mon Sep 17 00:00:00 2001 From: metacryst Date: Fri, 15 Mar 2024 16:21:51 -0500 Subject: [PATCH] adding field parse case for when there is no default field value --- index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 627e753..645ca85 100644 --- a/index.js +++ b/index.js @@ -32,12 +32,11 @@ window.Registry = class Registry { braceDepth -= (trimmedLine.match(/}/g) || []).length; // Check if the line is outside any function/method (top-level within the class) - if (braceDepth === 1 && trimmedLine.includes('=') && !trimmedLine.startsWith('...')) { - // Extract the field name, which is before the '=' symbol - const fieldName = trimmedLine.split('=')[0].trim(); - // Make sure the field name doesn't include invalid characters or spaces - if (!fieldName.includes(' ') && !fieldName.startsWith('this.')) { - fields.push(fieldName); + if (braceDepth === 1) { + // Attempt to match a class field declaration with or without initialization + const fieldMatch = trimmedLine.match(/^([a-zA-Z_$][0-9a-zA-Z_$]*)\s*(=|;|\n|$)/); + if (fieldMatch) { + fields.push(fieldMatch[1]); } }