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

Function dedent

packages/core/test/render3/utils.ts:10–28  ·  view source on GitHub ↗
(strings: TemplateStringsArray, ...values: any[])

Source from the content-addressed store, hash-verified

8
9/** Template string function that can be used to strip indentation from a given string literal. */
10export function dedent(strings: TemplateStringsArray, ...values: any[]) {
11 let joinedString = '';
12 for (let i = 0; i < values.length; i++) {
13 joinedString += `${strings[i]}${values[i]}`;
14 }
15 joinedString += strings[strings.length - 1];
16 const lines = joinedString.split('\n');
17 while (isBlank(lines[0])) {
18 lines.shift();
19 }
20 while (isBlank(lines[lines.length - 1])) {
21 lines.pop();
22 }
23 let minWhitespacePrefix = lines.reduce(
24 (min, line) => Math.min(min, numOfWhiteSpaceLeadingChars(line)),
25 Number.MAX_SAFE_INTEGER,
26 );
27 return lines.map((line) => line.substring(minWhitespacePrefix)).join('\n');
28}
29
30/**
31 * Tests to see if the line is blank.

Callers

nothing calls this directly

Calls 7

popMethod · 0.80
reduceMethod · 0.80
mapMethod · 0.80
isBlankFunction · 0.70
joinMethod · 0.65
minMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…