* Compare two strings by character frequency (order-agnostic)
(a: string, b: string)
| 250 | * Compare two strings by character frequency (order-agnostic) |
| 251 | */ |
| 252 | function sameCharFrequency(a: string, b: string): boolean { |
| 253 | const trimmedA = a.trim() |
| 254 | const trimmedB = b.trim() |
| 255 | if (trimmedA.length !== trimmedB.length) return false |
| 256 | |
| 257 | const dictA = charCountDict(trimmedA) |
| 258 | const dictB = charCountDict(trimmedB) |
| 259 | |
| 260 | if (dictA.size !== dictB.size) return false |
| 261 | |
| 262 | for (const [char, count] of dictA) { |
| 263 | if (dictB.get(char) !== count) return false |
| 264 | } |
| 265 | return true |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * Replace specific parts of XML content using search and replace pairs |
no test coverage detected