API reference@evolu/commonEq › eqData

function eqData<Actual, Expected>(
  actual: Actual,
  expected: Expected,
  ...dataError: EqDataError<Actual | Expected>
): boolean;

Defined in: packages/common/src/Eq.ts:267

Deeply compares two Data values using platform-independent structural equality.

Primitive values use Object.is. Arrays are ordered; plain Objects compare their own string-keyed properties regardless of property order or prototype; Sets and Maps ignore insertion order; Dates compare their time values; and Uint8Arrays compare their bytes. Cyclic and shared data graphs are supported.

Arguments are restricted to Data at compile time. Use the Data Type at an unknown boundary.

Example

import { assertTrue, eqData } from "@evolu/common";

interface User {
  readonly name: string;
  readonly roles: ReadonlySet<string>;
}

const first: User = { name: "Ada", roles: new Set(["admin", "author"]) };
const second: User = {
  name: "Ada",
  roles: new Set(["author", "admin"]),
};

assertTrue(eqData(first, second));