MCPcopy Create free account
hub / github.com/ReactiveX/rxjs / leftAlign

Function leftAlign

apps/rxjs.dev/src/app/custom-elements/code/code.component.ts:222–237  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

220}
221
222function leftAlign(text: string): string {
223 let indent = Number.MAX_VALUE;
224
225 const lines = text.split('\n');
226 lines.forEach((line) => {
227 const lineIndent = line.search(/\S/);
228 if (lineIndent !== -1) {
229 indent = Math.min(lineIndent, indent);
230 }
231 });
232
233 return lines
234 .map((line) => line.substr(indent))
235 .join('\n')
236 .trim();
237}

Callers 1

formatDisplayedCodeMethod · 0.85

Calls 3

mapMethod · 0.65
forEachMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected