Order-insensitive shallow structural equality of two integrations arrays (id/name/type).
(
a: ReadonlyArray<{ id: string; name?: string; type?: string }> | undefined,
b: ReadonlyArray<{ id: string; name?: string; type?: string }> | undefined
)
| 233 | |
| 234 | /** Order-insensitive shallow structural equality of two integrations arrays (id/name/type). */ |
| 235 | function areIntegrationsEqual( |
| 236 | a: ReadonlyArray<{ id: string; name?: string; type?: string }> | undefined, |
| 237 | b: ReadonlyArray<{ id: string; name?: string; type?: string }> | undefined |
| 238 | ): boolean { |
| 239 | if (a === undefined && b === undefined) return true |
| 240 | if (a === undefined || b === undefined) return (a?.length ?? 0) === (b?.length ?? 0) |
| 241 | if (a.length !== b.length) return false |
| 242 | |
| 243 | const sortById = <T extends { id: string }>(arr: ReadonlyArray<T>): ReadonlyArray<T> => |
| 244 | [...arr].sort((x, y) => x.id.localeCompare(y.id)) |
| 245 | |
| 246 | const aSorted = sortById(a) |
| 247 | const bSorted = sortById(b) |
| 248 | for (let i = 0; i < aSorted.length; i++) { |
| 249 | if (aSorted[i].id !== bSorted[i].id) return false |
| 250 | if ((aSorted[i].name ?? '') !== (bSorted[i].name ?? '')) return false |
| 251 | if ((aSorted[i].type ?? '') !== (bSorted[i].type ?? '')) return false |
| 252 | } |
| 253 | return true |
| 254 | } |
| 255 | |
| 256 | /** Structural equality of two settings objects via key-sorted JSON; treats `undefined`/`null` as equivalent. */ |
| 257 | function areSettingsEqual(a: unknown, b: unknown): boolean { |
no test coverage detected