MCPcopy Create free account
hub / github.com/deepnote/deepnote / areIntegrationsEqual

Function areIntegrationsEqual

packages/convert/src/snapshot/resolve-init.ts:235–254  ·  view source on GitHub ↗

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
)

Source from the content-addressed store, hash-verified

233
234/** Order-insensitive shallow structural equality of two integrations arrays (id/name/type). */
235function 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. */
257function areSettingsEqual(a: unknown, b: unknown): boolean {

Callers 1

resolveAndComposeInitFunction · 0.85

Calls 1

sortByIdFunction · 0.85

Tested by

no test coverage detected