An object literal's own properties, each name to its value's text — shorthand and methods included — and its spreads.
(text: string)
| 1916 | |
| 1917 | /** An object literal's own properties, each name to its value's text — shorthand and methods included — and its spreads. */ |
| 1918 | function 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 |
no test coverage detected