MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / wrappedName

Function wrappedName

src/resolution/frameworks/react.ts:647–665  ·  view source on GitHub ↗

* The component a wrapper call hands over — `observer(Login)`, `React.memo(Login)`, * `connect(mapState)(Login)`, `withTranslation()(withRouter(Login))`: its last * argument list's lone argument, or a component ahead of the options after it * (`React.memo(TableBody, areEqual)`, `withAuthZ(Page, {

(expression: string)

Source from the content-addressed store, hash-verified

645 * `forwardRef` drops).
646 */
647function wrappedName(expression: string): string | null {
648 const s = expression.trim();
649 const callee = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?:<[^()]*>)?\s*(?=\()/.exec(s);
650 if (!callee) return null;
651 let end = callee[0].length;
652 let args: string[] = [];
653 for (let open = end; s[open] === '('; ) {
654 const close = matchBracket(s, open);
655 if (close < 0) return null;
656 args = topLevelItems(s.slice(open + 1, close));
657 end = close + 1;
658 for (open = end; /\s/.test(s[open] ?? ''); ) open++;
659 }
660 if (!/^(?:\s+(?:as|satisfies)\s[\s\S]*)?$/.test(s.slice(end))) return null;
661 const first = args[0] ?? '';
662 // `connect(mapState, mapDispatch)` hands over no component yet.
663 if (args.length > 1 && !/^[A-Z]/.test(first)) return null;
664 return /^[A-Za-z_$][\w$]*$/.test(first) ? first : first ? wrappedName(first) : null;
665}
666
667/** True when the module's default export is the binding `local` itself: `export default Page;`, `export { Page as default }`. */
668function exportsBinding(source: string, local: string): boolean {

Callers 3

defaultExportedNameFunction · 0.85
handedComponentFunction · 0.85
wrappedComponentNameFunction · 0.85

Calls 3

matchBracketFunction · 0.90
topLevelItemsFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected