Function safeEqual

  • Compares a source object and values of entries against a target object. If the entries in the source object match the target object then true is returned otherwise false. If either object is undefined or null then false is returned.

    Note: The source and target should be ordinary objects or arrays; Map and Set entries are not compared. Present properties whose values are undefined or null remain distinct from missing properties. Comparison disables the normal pathKeyIterator result cap so a successful result is never based on a silently truncated path set. The visit budget remains enforced to bound unexpectedly broad source objects.

    Type Parameters

    • T extends object

    Parameters

    • source: T

      Source object.

    • target: object

      Target object.

    • Optionaloptions: { arrayIndex?: boolean; hasOwnOnly?: boolean; maxVisits?: number }

      Options.

      • OptionalarrayIndex?: boolean

        Set to true to include equality testing for numeric array indexes; default: false.

      • OptionalhasOwnOnly?: boolean

        Set to false to include enumerable prototype properties; default: true.

      • OptionalmaxVisits?: number

        Maximum number of enumerable source properties or array indexes inspected; default: 65536.

    Returns target is T

    True if equal.

    If an option is invalid.

    If options.maxVisits is exceeded.