API Reference / @evolu/common / Eq / eqJsonValueInput

Function: eqJsonValueInput()

function eqJsonValueInput(a, b): boolean;

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

Deeply compares two JsonValueInput values for equality.

  • Uses an iterative approach with a stack to handle large or deeply nested objects without risking stack overflow.
  • Handles circular references with a WeakMap to prevent infinite loops.
  • Unlike JSON.stringify, this function directly compares values, avoiding serialization overhead and leveraging short-circuit evaluation for faster failure on mismatched structures.

Example

const obj1: Json = { name: "Alice", hobbies: ["reading", "hiking"] };
const obj2: Json = { name: "Alice", hobbies: ["reading", "hiking"] };
console.log(eqJson(obj1, obj2)); // true

Parameters

ParameterType
aJsonValueInput
bJsonValueInput

Returns

boolean

Was this page helpful?