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

Function objectEntries

src/resolution/frameworks/react.ts:1918–1931  ·  view source on GitHub ↗

An object literal's own properties, each name to its value's text — shorthand and methods included — and its spreads.

(text: string)

Source from the content-addressed store, hash-verified

1916
1917/** An object literal's own properties, each name to its value's text — shorthand and methods included — and its spreads. */
1918function objectEntries(text: string): { props: Map<string, string>; spreads: string[] } {
1919 const props = new Map<string, string>();
1920 const spreads: string[] = [];
1921 for (const entry of topLevelEntries(text)) {
1922 const spread = /^\.\.\.\s*([\s\S]+)$/.exec(entry);
1923 const pair = spread ? null : /^(?:([A-Za-z_$][\w$]*)|(["'])([A-Za-z_$][\w$]*)\2)\s*:\s*([\s\S]+)$/.exec(entry);
1924 const method = spread || pair ? null : /^(async\s+)?([A-Za-z_$][\w$]*)\s*\(/.exec(entry);
1925 if (spread) spreads.push(spread[1]!);
1926 else if (pair) props.set(pair[1] ?? pair[3]!, pair[4]!);
1927 else if (method) props.set(method[2]!, `${method[1] ?? ''}function ${entry.slice(method[0].length - 1)}`);
1928 else if (/^[A-Za-z_$][\w$]*$/.test(entry)) props.set(entry, entry);
1929 }
1930 return { props, spreads };
1931}
1932
1933// =============================================================================
1934// Route tables another file hands the router

Callers 5

loaderOfFunction · 0.85
loadedPageFunction · 0.85
routeRenderFunction · 0.85
lazyPropertiesRenderFunction · 0.85
memberOfFunction · 0.85

Calls 4

topLevelEntriesFunction · 0.85
pushMethod · 0.80
execMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected