A shared-helper name: common words across the member names, else a common prefix, else generic.
(names: string[])
| 67 | |
| 68 | /** A shared-helper name: common words across the member names, else a common prefix, else generic. */ |
| 69 | function suggestName(names: string[]): string { |
| 70 | const wordSets = names.map(splitWords); |
| 71 | if (wordSets.length && wordSets[0]!.length) { |
| 72 | const common = wordSets[0]!.filter(w => wordSets.every(set => set.includes(w))); |
| 73 | if (common.length) { |
| 74 | const [head, ...rest] = common; |
| 75 | return head + rest.map(w => w[0]!.toUpperCase() + w.slice(1)).join(''); |
| 76 | } |
| 77 | } |
| 78 | return 'extractedHelper'; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Cluster functions into near-duplicate groups by structural similarity. Returns clusters of ≥2, |
no outgoing calls
no test coverage detected