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

Function dedent

packages/core/schematics/utils/tsurge/testing/dedent.ts:14–31  ·  view source on GitHub ↗
(strings: TemplateStringsArray, ...values: any[])

Source from the content-addressed store, hash-verified

12 * Additionally, whitespace in empty lines is removed.
13 */
14export function dedent(strings: TemplateStringsArray, ...values: any[]) {
15 let joinedString = '';
16 for (let i = 0; i < values.length; i++) {
17 joinedString += `${strings[i]}${values[i]}`;
18 }
19 joinedString += strings[strings.length - 1];
20
21 const matches = joinedString.match(/^[ \t]*(?=\S)/gm);
22 if (matches === null) {
23 return joinedString;
24 }
25
26 const minLineIndent = Math.min(...matches.map((el) => el.length));
27 const omitMinIndentRegex = new RegExp(`^[ \\t]{${minLineIndent}}`, 'gm');
28 const omitEmptyLineWhitespaceRegex = /^[ \t]+$/gm;
29 const result = minLineIndent > 0 ? joinedString.replace(omitMinIndentRegex, '') : joinedString;
30 return result.replace(omitEmptyLineWhitespaceRegex, '');
31}

Callers 3

compareFunction · 0.90
migration.spec.tsFile · 0.90

Calls 4

mapMethod · 0.80
matchMethod · 0.45
minMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…