Function isEqual

Deeply compares 2 input values, returning true if they are considered equal, with loads of awesome options!

Similar to lodash's _.isEqual, but:

  • adds loads of extra options, for example use .isEquals() of the values if it exists, like one-side similarity comparisons, exact refs required (shallow clones), inherited or exclude props, get the path of where the difference was found and loads more!

IisEqualOptions *

  • It supports all types, including Map, Set, WeakMap, WeakSet, ArrayBuffer, Error, RegExp, Date, Symbol, BigInt, TypedArray, Promise, class, function, arguments, null, undefined, NaN, realObject and more.
  • You can also use any of IKeysOptions to control which keys are compared, as IisEqualOptions extends IKeysOptions!
    • when props: true, only props matter, not the actual values! *

Note: it is NOT 100% compatible to lodash, mostly for good reasons. Few minor edge cases are not implemented yet as options, and current default deemed better and so kept different to lodash. Search z.isEqual DIFFERENT in src/code/objects/isEqual-lodash-spec.ts, where lodash tests are also tested against z.isEqual, with differences highlighted.

The first value to compare

The second value to compare

The function to customize comparisons. If undefined, comparisons are handled by z.isEqual. If customizer is passed as a property of the options object, it will be used instead of this argument. You can also pass the options object as the 3rd argument, in place of customizer.

The this binding (aka context) of customizer. If undefined, this is bound to the global object. If ctx is passed as a property of the options object, it will be used instead of this argument.

The options object - see above. It can also be passed as the 3rd argument, in place of customizer.

true if the input values are "equal" (based on options), false otherwise

  • Parameters

    • a: any

      The first value to compare.

    • b: any

      The second value to compare.

    • Optionalcustomizer: IsEqualCustomizerCallback

      The function to customize comparisons. If undefined, comparisons are handled by z.isEqual. If customizer is passed as a property of the options object, it will be used instead of this argument. You can also pass the options object as the 3rd argument, in place of customizer.

    • Optionalctx: any

      The this binding (aka context) of customizer. If undefined, this is bound to the global object. If ctx is passed as a property of the options object, it will be used instead of this argument.

    • OptionalisEqualOptions: IsEqualOptions

      The options object - see above.

    Returns boolean

  • Parameters

    • a: any

      The first input value to compare.

    • b: any

      The second input value to compare.

    • OptionalisEqualOptions: IsEqualOptions

      The options object can be the 3rd argument (instead of customizer).

    • Optionalctx: any

      The this binding (aka context) of customizer. If undefined, this is bound to the global object. If ctx is passed as a property of the options object, it will be used instead of this argument.

    Returns boolean