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

Function defaultExportedName

src/resolution/frameworks/react.ts:629–636  ·  view source on GitHub ↗

* The name a module's default export carries: `export default Login`, * `export default function Login`, `export default class Login`, `export * default Login as FC`, or the component a wrapper call hands over — * `observer(Login)`, `React.memo(Login)`, `connect(mapState)(Login)`, * `withTransla

(source: string)

Source from the content-addressed store, hash-verified

627 * `withTranslation()(withRouter(Login))`.
628 */
629function defaultExportedName(source: string): string | null {
630 const at = /\bexport\s+default\s+/.exec(source);
631 if (!at) return null;
632 const rest = source.slice(at.index + at[0].length);
633 const named = /^(?:async\s+)?(?:function\s*\*?\s*|class\s+)([A-Za-z_$][\w$]*)/.exec(rest) ??
634 /^([A-Za-z_$][\w$]*)(?:[ \t]*(?:;|\r?\n|$)|\s+(?:as|satisfies)\s)/.exec(rest);
635 return named ? named[1]! : wrappedName(rest.slice(0, statementEnd(rest, 0)));
636}
637
638/**
639 * The component a wrapper call hands over — `observer(Login)`, `React.memo(Login)`,

Callers 1

ownExportFunction · 0.85

Calls 3

wrappedNameFunction · 0.85
statementEndFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected