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

Function loaderOf

src/resolution/frameworks/react.ts:766–786  ·  view source on GitHub ↗

* The loader function an initializer hands a lazy wrapper: the first function * among its call's arguments, through the wrappers around it (`Loadable(lazy(() * => import('./x')))`) and before the options after it (`dynamic(…, { ssr: * false })`), or an options object's `loader` (`Loadable({ loade

(text: string)

Source from the content-addressed store, hash-verified

764 * import(…) })`). Null for an initializer that is no such call.
765 */
766function loaderOf(text: string): string | null {
767 const s = text.trim();
768 const call = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?:<[^()]*>)?\s*\(/.exec(s);
769 if (!call) return conditionalLoader(s);
770 const open = call[0].length - 1;
771 const close = matchBracket(s, open);
772 if (close < 0) return null;
773 for (const arg of topLevelItems(s.slice(open + 1, close))) {
774 const item = arg.trim();
775 if (!item) continue;
776 if (functionParts(item)) return item;
777 if (item.startsWith('{')) {
778 const loader = matchBracket(item, 0) === item.length - 1 ? objectEntries(item.slice(1, -1)).props.get('loader') : undefined;
779 if (loader !== undefined && functionParts(loader)) return loader;
780 continue;
781 }
782 const inner = loaderOf(item);
783 if (inner) return inner;
784 }
785 return conditionalLoader(s);
786}
787
788/**
789 * The loader of a conditional's one branch that has one: SigNoz's `IS_DEV ?

Callers 1

valueLoaderFunction · 0.85

Calls 7

matchBracketFunction · 0.90
conditionalLoaderFunction · 0.85
functionPartsFunction · 0.85
objectEntriesFunction · 0.85
topLevelItemsFunction · 0.70
execMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected