* Returns the most common indent string among the sources, falling back to a tab.
()
| 364 | * Returns the most common indent string among the sources, falling back to a tab. |
| 365 | */ |
| 366 | getIndentString(): string { |
| 367 | const indentStringCounts = new Map<string, number>() |
| 368 | |
| 369 | this.sources.forEach((source) => { |
| 370 | const indentStr = source.content._getRawIndentString() |
| 371 | |
| 372 | if (indentStr == null) |
| 373 | return |
| 374 | |
| 375 | indentStringCounts.set(indentStr, (indentStringCounts.get(indentStr) ?? 0) + 1) |
| 376 | }) |
| 377 | |
| 378 | return [...indentStringCounts.entries()].sort(([, a], [, b]) => b - a)[0]?.[0] ?? '\t' |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Prefixes each line of every source and of the intro with `indentStr`, guessed with `getIndentString()` |
no test coverage detected