* Create a character count dictionary from a string * Used for attribute-order agnostic comparison
(str: string)
| 239 | * Used for attribute-order agnostic comparison |
| 240 | */ |
| 241 | function charCountDict(str: string): Map<string, number> { |
| 242 | const dict = new Map<string, number>() |
| 243 | for (const char of str) { |
| 244 | dict.set(char, (dict.get(char) || 0) + 1) |
| 245 | } |
| 246 | return dict |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Compare two strings by character frequency (order-agnostic) |