Function makeIsDeepEqual

Creates a function that checks if two values are deeply equal.

const isDeepEqual = makeIsDeepEqual();
isDeepEqual(null)(null); // true
isDeepEqual(null)(undefined); // false
const isDeepEqual2 = makeIsDeepEqual({ strictNullComparison: false });
isDeepEqual2(null)(undefined); // true
const isDeepEqual3 = makeIsDeepEqual({ maxDepth: 2 });
isDeepEqual3({ a: { b: { c: 1 } } })({ a: { b: { c: 1 } } }); // false
  • Parameters

    • options: {
          maxDepth?: number;
          optimizeForReact?: boolean;
          strictNullComparison?: boolean;
      } = {}

      The options for deep equality comparison with properties:

      • optimizeForReact: Whether to optimize for React elements. Default is true.
      • maxDepth: The maximum depth to traverse nested objects. Default is -1 (unlimited depth).
      • strictNullComparison: Whether to strictly compare null values. Default is true.

    Returns (a: unknown) => (b: unknown) => boolean

    A function that takes two values and returns true if they are deeply equal, false otherwise.