(name: string)
| 28 | * ("base64Encode" → base64/encode). Digit-only fragments are dropped. |
| 29 | */ |
| 30 | export function splitIdentifierSegments(name: string): string[] { |
| 31 | if (!name) return []; |
| 32 | const out = new Set<string>(); |
| 33 | for (const run of name.match(/[\p{L}\p{N}]+/gu) ?? []) { |
| 34 | // Split before an Upper that follows lower/digit (camelCase hump), and |
| 35 | // before the last Upper of an acronym run when a lowercase follows |
| 36 | // ("HTMLParser" → HTML | Parser). |
| 37 | const parts = run.split(/(?<=[\p{Ll}\p{N}])(?=\p{Lu})|(?<=\p{Lu})(?=\p{Lu}\p{Ll})/u); |
| 38 | for (const part of parts) { |
| 39 | if (out.size >= MAX_SEGMENTS_PER_NAME) return [...out]; |
| 40 | const seg = part.toLowerCase(); |
| 41 | if (seg.length < MIN_SEGMENT_CHARS || seg.length > MAX_SEGMENT_CHARS) continue; |
| 42 | if (/^\p{N}+$/u.test(seg)) continue; |
| 43 | out.add(seg); |
| 44 | } |
| 45 | } |
| 46 | return [...out]; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Normalize a prose word for segment lookup: lowercase + strip diacritics |
no outgoing calls
no test coverage detected