Skip to content

Commit

Permalink
abstract placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
nialexsan committed Sep 18, 2024
1 parent ee5d621 commit c7f8fa0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/util/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ export const collapseSpaces = (input: string) => input.replace(/\s+/g, ' ');
export const stripNewLines = (input: string) =>
input.replace(/\r\n|\n|\r/g, ' ');

const COMMA_PLACEHOLDER = '<COMMA>';

export const generateSchema = (argsDefinition: string) =>
argsDefinition
.replace(/\(([^()]+)\)/g, (match) => {
// Replace commas with placeholder inside the parentheses content
return match.replace(/,/g, '<COMMA>');
return match.replace(/,/g, COMMA_PLACEHOLDER);
})
.split(',')
.map((item) => item.replace(/\s*/g, '').replace(/<COMMA>/g, ','))
.map((item) =>
item.replace(/\s*/g, '').replace(new RegExp(COMMA_PLACEHOLDER, 'g'), ','),
)
.filter((item) => item !== '');

export const stripComments = (code: string) => {
Expand Down

0 comments on commit c7f8fa0

Please sign in to comment.