MCPcopy Create free account
hub / github.com/angular/components / dedent

Function dedent

src/cdk/testing/private/text-dedent.ts:13–28  ·  view source on GitHub ↗
(strings: TemplateStringsArray, ...values: any[])

Source from the content-addressed store, hash-verified

11 * literal. The smallest common indentation will be omitted.
12 */
13export function dedent(strings: TemplateStringsArray, ...values: any[]) {
14 let joinedString = '';
15 for (let i = 0; i < values.length; i++) {
16 joinedString += `${strings[i]}${values[i]}`;
17 }
18 joinedString += strings[strings.length - 1];
19
20 const matches = joinedString.match(/^[ \t]*(?=\S)/gm);
21 if (matches === null) {
22 return joinedString;
23 }
24
25 const minLineIndent = Math.min(...matches.map(el => el.length));
26 const omitMinIndentRegex = new RegExp(`^[ \\t]{${minLineIndent}}`, 'gm');
27 return minLineIndent > 0 ? joinedString.replace(omitMinIndentRegex, '') : joinedString;
28}

Callers

nothing calls this directly

Calls 1

minMethod · 0.45

Tested by

no test coverage detected