( before: Map<string, V>, after: Map<string, V>, )
| 159 | * Diff two Maps — returns added, removed, and modified keys. |
| 160 | */ |
| 161 | export function diffMaps<V>( |
| 162 | before: Map<string, V>, |
| 163 | after: Map<string, V>, |
| 164 | ): { added: string[]; removed: string[]; modified: string[] } { |
| 165 | const added: string[] = []; |
| 166 | const removed: string[] = []; |
| 167 | const modified: string[] = []; |
| 168 | |
| 169 | for (const key of after.keys()) { |
| 170 | if (!before.has(key)) { |
| 171 | added.push(key); |
| 172 | } else if (JSON.stringify(before.get(key)) !== JSON.stringify(after.get(key))) { |
| 173 | modified.push(key); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | for (const key of before.keys()) { |
| 178 | if (!after.has(key)) { |
| 179 | removed.push(key); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return { added, removed, modified }; |
| 184 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…