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

Function objectEntries

src/resolution/frameworks/react.ts:1940–1953  ·  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

1938
1939/** An object literal's own properties, each name to its value's text — shorthand and methods included — and its spreads. */
1940function objectEntries(text: string): { props: Map<string, string>; spreads: string[] } {
1941 const props = new Map<string, string>();
1942 const spreads: string[] = [];
1943 for (const entry of topLevelEntries(text)) {
1944 const spread = /^\.\.\.\s*([\s\S]+)$/.exec(entry);
1945 const pair = spread ? null : /^(?:([A-Za-z_$][\w$]*)|(["'])([A-Za-z_$][\w$]*)\2)\s*:\s*([\s\S]+)$/.exec(entry);
1946 const method = spread || pair ? null : /^(async\s+)?([A-Za-z_$][\w$]*)\s*\(/.exec(entry);
1947 if (spread) spreads.push(spread[1]!);
1948 else if (pair) props.set(pair[1] ?? pair[3]!, pair[4]!);
1949 else if (method) props.set(method[2]!, `${method[1] ?? ''}function ${entry.slice(method[0].length - 1)}`);
1950 else if (/^[A-Za-z_$][\w$]*$/.test(entry)) props.set(entry, entry);
1951 }
1952 return { props, spreads };
1953}
1954
1955// =============================================================================
1956// 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