MCPcopy Create free account
hub / github.com/angular/angular / normalizeWhitespace

Function normalizeWhitespace

packages/compiler-cli/preprocessor/test/utils.ts:648–670  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

646}
647
648function normalizeWhitespace(s: string): string {
649 let normalized = s
650 .split('\n')
651 .map((line) => line.trimEnd())
652 .join('\n')
653 .trim();
654
655 // Normalize Prettier 3.8 vs 3.9 semicolon placement for trailing block comments on statements.
656 // Only consider comments on the same line as the semicolon, otherwise we'd also capture
657 // leading comments of the next statement.
658 while (true) {
659 const next = normalized.replace(/;[ \t]*(\/\*[\s\S]*?\*\/)/g, ' $1;');
660 if (next === normalized) break;
661 normalized = next;
662 }
663
664 // Normalize return types on functions and arrow functions (: any) so differences between
665 // compiler versions or golden snapshots do not cause spurious mismatches.
666 normalized = normalized.replace(/\):\s*any\s*=>/g, ') =>');
667 normalized = normalized.replace(/\):\s*any\s*\{/g, ') {');
668
669 return normalized;
670}

Callers 2

checkMatchFunction · 0.85
compareOutputsFunction · 0.85

Calls 3

mapMethod · 0.80
joinMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected