Skip to content

Commit

Permalink
feat: apply PR review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Nov 20, 2024
1 parent 3e81545 commit fcceaba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const parseLine = (() => {
if (char === ';' && openParens === 0) {
// Start semicolon comment outside parentheses
comments.push(line.slice(i + 1).trim());
openParens = 0; // Reset parentheses counter
break; // Stop further processing after a semicolon comment
}

Expand All @@ -105,10 +106,10 @@ const parseLine = (() => {
} else if (openParens > 0) {
currentComment += char;
}
openParens += 1;
openParens = Math.min(openParens + 1, Number.MAX_SAFE_INTEGER);
} else if (char === ')') {
// End parentheses comment
openParens = Math.max(0, openParens - 1); // Prevent negative values
openParens = Math.max(0, openParens - 1);
if (openParens === 0) {
comments.push(currentComment.trim());
currentComment = '';
Expand All @@ -124,7 +125,7 @@ const parseLine = (() => {
}
}

result = result.trim(); // Ensure result is clean after parsing
result = result.trim();
return [result, comments];
};

Expand Down

0 comments on commit fcceaba

Please sign in to comment.