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

Function unquoteSpecifier

src/resolution/import-resolver.ts:2183–2196  ·  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

2181
2182/** A string-named specifier's name without its quotes, escapes decoded. */
2183function unquoteSpecifier(name: string): string {
2184 if (!/^["']/.test(name)) return name;
2185 return name.slice(1, -1).replace(
2186 /\\(u\{[0-9a-fA-F]+\}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[\s\S])/g,
2187 (_, esc: string) => {
2188 if (esc[0] === 'u' || esc[0] === 'x') {
2189 const hex = esc[1] === '{' ? esc.slice(2, -1) : esc.slice(1);
2190 const code = parseInt(hex, 16);
2191 return code <= 0x10ffff ? String.fromCodePoint(code) : esc;
2192 }
2193 return SIMPLE_ESCAPES[esc] ?? esc;
2194 }
2195 );
2196}
2197
2198/**
2199 * 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