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

Function unquoteSpecifier

src/resolution/import-resolver.ts:2102–2115  ·  view source on GitHub ↗

A string-named specifier's name without its quotes, escapes decoded.

(name: string)

Source from the content-addressed store, hash-verified

2100
2101/** A string-named specifier's name without its quotes, escapes decoded. */
2102function unquoteSpecifier(name: string): string {
2103 if (!/^["']/.test(name)) return name;
2104 return name.slice(1, -1).replace(
2105 /\\(u\{[0-9a-fA-F]+\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[\s\S])/g,
2106 (_, esc: string) => {
2107 if (esc[0] === 'u' || esc[0] === 'x') {
2108 const hex = esc[1] === '{' ? esc.slice(2, -1) : esc.slice(1);
2109 const code = parseInt(hex, 16);
2110 return code <= 0x10ffff ? String.fromCodePoint(code) : esc;
2111 }
2112 return SIMPLE_ESCAPES[esc] ?? esc;
2113 }
2114 );
2115}
2116
2117/**
2118 * One `{ … }` import/export specifier — `a`, `a as b`, `"a-b" as c`, and the

Callers 1

parseSpecifierFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected