The non-test modules a given depth would draw, and how concentrated they are.
(
files: ReadonlyArray<{ path: string; symbols: number; test: boolean }>,
root: string,
depth: number,
passThrough?: ReadonlySet<string>
)
| 395 | |
| 396 | /** The non-test modules a given depth would draw, and how concentrated they are. */ |
| 397 | function tallyModules( |
| 398 | files: ReadonlyArray<{ path: string; symbols: number; test: boolean }>, |
| 399 | root: string, |
| 400 | depth: number, |
| 401 | passThrough?: ReadonlySet<string> |
| 402 | ): { count: number; share: number; largestFiles: number } { |
| 403 | const byModule = new Map<string, { symbols: number; files: number }>(); |
| 404 | let total = 0; |
| 405 | for (const file of files) { |
| 406 | if (file.test) continue; |
| 407 | const assigned = moduleIdFor(file.path, root, depth, passThrough); |
| 408 | if (assigned === null) continue; |
| 409 | let entry = byModule.get(assigned.id); |
| 410 | if (!entry) byModule.set(assigned.id, (entry = { symbols: 0, files: 0 })); |
| 411 | entry.symbols += file.symbols; |
| 412 | entry.files += 1; |
| 413 | total += file.symbols; |
| 414 | } |
| 415 | let largest = { symbols: 0, files: 0 }; |
| 416 | for (const entry of byModule.values()) { |
| 417 | if (entry.symbols > largest.symbols) largest = entry; |
| 418 | } |
| 419 | return { |
| 420 | count: byModule.size, |
| 421 | share: total === 0 ? 0 : largest.symbols / total, |
| 422 | largestFiles: largest.files, |
| 423 | }; |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * How many segments name a module, when the reader has not said. |
no test coverage detected