Function makeIsDeepEqual

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

https://jmlweb.github.io/mochila/functions/isDeepEqual.html

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.

      • OptionalmaxDepth?: number

        The maximum depth to traverse nested objects. Default is -1 (unlimited depth).

      • OptionaloptimizeForReact?: boolean

        Whether to optimize for React elements. Default is true.

      • OptionalstrictNullComparison?: boolean

        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.

      • (a): ((b: unknown) => boolean)
      • Parameters

        • a: unknown

        Returns ((b: unknown) => boolean)

          • (b): boolean
          • Parameters

            • b: unknown

            Returns boolean