MCPcopy Index your code
hub / github.com/angular/angular / escapeIdentifier

Function escapeIdentifier

packages/compiler/src/output/abstract_emitter.ts:725–742  ·  view source on GitHub ↗
(input: string, alwaysQuote: boolean = true)

Source from the content-addressed store, hash-verified

723}
724
725export function escapeIdentifier(input: string, alwaysQuote: boolean = true): string | null {
726 if (input == null) {
727 return null;
728 }
729
730 const body = input.replace(SINGLE_QUOTE_ESCAPE_STRING_RE, (...match: string[]) => {
731 if (match[0] == '\n') {
732 return '\\n';
733 } else if (match[0] == '\r') {
734 return '\\r';
735 } else {
736 return `\\${match[0]}`;
737 }
738 });
739
740 const requiresQuotes = alwaysQuote || !LEGAL_IDENTIFIER_RE.test(body);
741 return requiresQuotes ? `'${body}'` : body;
742}

Callers 7

visitLocalizedStringFunction · 0.90
visitLiteralExprFunction · 0.85
visitDynamicImportExprFunction · 0.85
visitLiteralMapExprFunction · 0.85

Calls 2

replaceMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…