MCPcopy Create free account
hub / github.com/cometchat/cometchat-uikit-angular / extractInputs

Function extractInputs

scripts/docs-audit.ts:166–183  ·  view source on GitHub ↗

* Extracts @Input() property names from a component .ts file using regex. * * Handles patterns: * - @Input() propName = value; * - @Input() propName?: Type; * - @Input() propName!: Type; * - @Input() propName: Type = value; * - @Input({ transform: booleanAttribute }) propName = false; * - @I

(componentFilePath: string)

Source from the content-addressed store, hash-verified

164 * - @Input({ required: true }) propName!: Type;
165 */
166function extractInputs(componentFilePath: string): string[] {
167 const content = fs.readFileSync(componentFilePath, 'utf-8');
168 const inputs: string[] = [];
169
170 // Pattern 1: @Input() or @Input({...}) followed by property name (field or setter)
171 // Handles both single-line and multi-line (decorator on one line, property on next)
172 const inputRegex = /@Input\s*\([^)]*\)\s*(?:\n\s*)?(?:set\s+)?(\w+)\s*[?!]?\s*[=:(]/g;
173 let match: RegExpExecArray | null;
174
175 while ((match = inputRegex.exec(content)) !== null) {
176 const propName = match[1];
177 if (propName && !inputs.includes(propName)) {
178 inputs.push(propName);
179 }
180 }
181
182 return inputs.sort();
183}
184
185/**
186 * Extracts @Output() property names from a component .ts file using regex.

Callers 1

auditComponentFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected